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.