Do we need to manually release the sprite?

Do we need to manually release the sprite?
0.0 0


In the javascript demo MoonWarriors, there is following code:

var BackSky = cc.Sprite.extend({
ctor:function () {
destroy:function () {
this.setVisible(false); = false;

BackSky.create = function () {
var background = new BackSky();
return background;

Why doesn’t the destroy() call “this.release()” ? is this object autoreleaseable?


I am new to cocos2d-x but for what I have studied about Moon Warriors they are really not destroying the sprite because it is going to be reused, they are just setting it inactive (you cannot inactivate a sprite with = false, since this is not a native variable, it is just a convenient variable used at this particular logic). That’s why at moment of creation you will see the function getOrCreateXXXX (if it is already created, and it is from the same type, but inactive, select it again, reinitialise and re-activate it). After the creation of first instance, it is not released from memory during the game, but released automatically by cocos2d-x when replacing scene (Please, someone correct me if I am wrong). So, if you are implementing what they did, keep in mind that you should reuse inactive sprites and not keep creating new ones when one is available for reuse, only create when all created sprites are active. I hope this helps.