How to remove Sprite From LayerManager?

Hello everybody!
When I need to add Sprite to a LayerManager,
the method is .append();
but if I want to remove the Sprite from LayerManager, How should I do?
Thank you for answering my question!
Thank you! :slight_smile:

hi. iv read a book (MIDP game programming) that there is a method called ā€œdeleteSpriteā€ now i dont have that book to look at it again on how to do it… i tried it on the layerManager but it is not a method of it… but i havent tried yet if it is a method of Sprite class… you should try it though… if am not busy ill reply to you later to help you… HEY GUYS! HELP THIS GUY OUT! ;D

Check the MIDP 2.0 JavaDocs: LayerManager has a method ā€˜remove’ to remove a Layer from it (remember that Sprites and TiledLayers are both Layers).

david… i tried that method

this is in the javadoc:
layerManager.remove(Layer 1);

Layer 1 means the index of the layer I want to remove…

i tried this one a few weeks ago but it failed…
layerManager.remove(2);

if my sprite is at layer 2

i dunno. pls check it again… I’LL just reply if i have time

No, that’s not a number ā€˜1’, that’s a letter ā€˜l’. I.e. you don’t call:
layerManager.remove(2);
but instead you call:
layerManager.remove(mySprite);

If you’ve got Forum Nokia’s ā€œNokia Developer Suite for J2ME 2.2ā€, have a look at MIDlet ā€˜Hawk’ in directory midp_2_0_examples (especially see method ā€˜tick’ of class ā€˜HawkCanvas’). You’ll see that fired missiles are added using method ā€˜insert’ and removed using method ā€˜remove’. This works for me both in various emulators and in my Nokia 6600.