Reputation: 973
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);
}
Upvotes: 0
Views: 166
Reputation: 4411
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
Upvotes: 1