java - How to remove Sprite/Object from ArrayList? -


this question exact duplicate of:

i created arraylist sprites needs removed, when sprites touched added arraylist.

 //drawing enemy spawns , making them move          public void draw(spritebatch batch){             for(sprite drawenemy:enemies) {                 drawenemy.draw(batch);                 drawenemy.translatey(deltatime * movement);             touchinput(drawenemy.getx(),drawenemy.getwidth(),drawenemy);//2nd method             }          }        public void touchinput(float x,float w,sprite sprite){             float touchx=gdx.input.getx();              if(gdx.input.justtouched()){                 if(touchx > x && touchx < x+w ){                    removeene.add(sprite);// adding current sprite array list when touched                 }                        //removeene arraylist             }          } 

iterator<sprite> = removeene.iterator(); while (it.hasnext()) {      it.remove();  } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -