开发者

Check if a CCSprite is added to the Layer

I want to be able to check if the sprite has been added (using [self add开发者_Go百科Child]) to my Layer.

Is there a BOOL like sprite.isAdded or something similar? Or do I have to search through the array of children in the layer?


While adding your child, you can set the tag.

define ktag 1

CCSprite *sprite=[CCSprite spriteWithFile:@"xxx.png"];
sprite.position=ccp(200,200);
[self addChild:sprite tag:ktag];

if you want to check, u can use [self getChildbyTag:ktag]


if you are adding it properly then it will definitely get added and accordingly will appear on the layer. Anyways why you need to check? Though I am new to cocos2d, as per my searching there no such way to check the sprite is added or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜