質問

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