0

i have used linkedlist to make the sprite display in cocos2d-android game app, if the sprite is destroyed it should get permanently destroyed and get removed, but this sprite disappears and again appears, dont know how to remove the sprite permanently, any helps? This is the code for delete.

for (CCSprite ship2 : shipsToDelete)
    {
        _ships2.remove(ship2);
        removeChild(ship2, true);

        }
DD.
  • 973
  • 2
  • 10
  • 32

2 Answers2

1
LinkedHashMap<Object, Object> hashMap1;
LinkedHashMap<Object, Object> hashMap2 ;

for (Object key : hashMap1.keySet()) {
    hashMap2.remove(key);
}

 for (CCSprite ship2 : shipsToDelete){
     if(_ships2.contains(ship2){ 
      _ships2.remove(ship2);
      removeChild(ship2, true);
     }
 }

This will work only if _ships2 = shipsToDelete; but the item from both _ships2 , shipsToDelete will be remove , i thing it wont enter to if clause when _ships2 = shipsToDelete.clone() , so you have to use liked hashmap or exact object reference

Sandeep P
  • 4,291
  • 2
  • 26
  • 45
  • thanks for your reply, i have used like this protected LinkedList _ships2; in cocos2d the default keyword for any object is CCSprite, so how will i used the above code? @Sandy09 – DD. Jun 15 '13 at 09:30
0

In the destructor Call function.

CC_SAFE_RELEASE(_object);
lazyandroid
  • 157
  • 1
  • 10