문제

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