I create 10 sprites in a for loop and add them to an array:

this.mysprite = new mysprite()
this.addChild(this.mysprite)
sprite_array.push(this.mysprite)

I then remove a sprite:

shared_game_layer.removeChild(sprite_array[0], true);   

I then use another for loop to perform some actions on the sprites that have not been removed, wanting to bypass the removed sprites. The following code is executed before and after the sprite has been removed however the console always logs "y"

if (sprite_array[0])
    console.log("y");
else
    console.log("n");
有帮助吗?

解决方案

You can call the getParent function and see if the pointer to the Parent returned is nil.

if (sprite_array[0]->getParent())
    console.log("y");
else
    console.log("n");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top