2013-07-02 1 views
3

매우 사소한 것으로 여겨지면 죄송합니다. 나는 그것을 얻지 못하고있다. 특정 스프라이트가 이미 레이어에 있는지 확인하는 방법은 무엇입니까? 기본적으로 레이어에 추가할지 여부를 결정하기 전에이를 확인해야합니다.스프라이트가 레이어에 있는지 확인하는 방법

답변

6
if ([ myNode.children indexOfObject:sprite ] == NSNotFound) { 

    // you can add the code here 

} 
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 
}