Вопрос

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