Frage

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");
War es hilfreich?

Lösung

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");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top