对不起,如果这听起来很微不足道。我只是不明白。如何确定一个特定的精灵是否已经在图层中?基本上,我需要在确定是否将其添加到图层之前检查这一点。
问问题
711 次
2 回答
6
if ( [ myNode.children indexOfObject:sprite ] == NSNotFound ) {
// you can add the code here
}
于 2013-07-02T16:01:59.920 回答
1
有很多方法:
1)尝试得到孩子
if (![layer getChild:sprite]) {
// Your code
}
2)尝试通过标签获取孩子
if (![layer getChildByTag:spriteTag]) {
// Your code
}
3)检查精灵是否在儿童数组上(如@oopology答案)
if ([layer.children indexOfObject:sprite] == NSNotFound) {
// Your code
}
于 2013-07-02T18:11:26.550 回答