2012-07-13 2 views
0

2 개의 CCLayers가 서로 쌓여 있습니다. 둘 다 터치가 가능합니다. 나는 최고의 CCLayer가 터치에 반응하고 소비하고, 맨 아래 레이어가 맨 위 레이어가 소비하는 터치에 반응하지 않기를 바란다.다중 터치 지원 CCLayer, 상단 레이어가 터치를 소모하지 않음

상부층이 닮은 CCTouchBegan 방법이있다 :

- (BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event 
{ 
    NSLog(@"touched!"); 

    CGPoint location = [touch locationInView:[touch view]]; 
    location = [[CCDirector sharedDirector] convertToGL:location]; 

    //DO STUFF WITH TOUCH 

    return YES; 
} 

바닥층이 닮은 CCTouchesEnded 방법 가지고

상단 층은하지
- (void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    //choose one of the touches to work with 
    UITouch *touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:[touch view]]; 
    location = [[CCDirector sharedDirector] convertToGL:location]; 

    //DO STUFF WITH THE TOUCH 
} 

결과가 있음을 감동을 소비하지 않거나 전혀 반응하지 않습니다. 맨 아래 계층 만이 터치에 응답합니다.

+0

질문에 대한 답변을 얻으려면 이보다 더 많은 정보가 필요합니다. 이 레이어에는 무엇이 포함되어 있습니까? 어떻게 지내고 있습니까? 화면에 어디에 추가됩니까? –

+0

@DustinRowland 완료. – TheDanman

+0

@ TheDanman은 터치를 '소비하는'레이어가 중요합니까? –

답변

0

첫 번째 레이어에 CCTargetedTouchDelegate의 메소드를 사용합니다. CCLayer는 CCStandardTouchDelegate로 자신을 등록합니다. 두 번째 레이어가 터치에 반응하는 이유입니다.

+0

상단 CCLayer를 CCTargetedTouchDelegate로 등록 할 수있는 방법이 있습니까? – TheDanman

+0

검색을 사용하십시오. http://stackoverflow.com/questions/11056222/touch-handled-by-two-layers – Morion

관련 문제