Search code examples
javascriptcocos2d-iphonecocos2d-js

How to completely delete a node in Cocos2d-js?


I have created a node with a sprite and when I use child.removeFromParent() on the node, although the node does disappear, I can still access to its contents such as the position of the sprite. I am worrying about what if I create many nodes and delete them immediately.

Would that cause a memory leak? Or how can I completely delete a node in Cocos2d-js?


Solution

  • I think cocos use an intern gc so maybe the life of an object lasts a bit after removing. Also you can use retain/release to manually managing the object. Retain when you create it and release when you delete it after a removeChild.