2013-01-07 1 views
0

나는 cocos2d에서 2 개의 스프라이트를 동시에 터치 할 때 어떻게 감지 할 수 있는지 알고 싶습니다. 나는 과일 닌자와 비슷한 게임을 만들고 블레이드에 두 개의 스프라이트를 동시에 부술 때 보너스 포인트를 추가하고 싶습니다. 나는 그런 식으로 시도했지만 작동하지 않습니다.코코스 2d는 과일 닌자 게임 에서처럼 두 스프라이트에서 동시 터치를 감지합니다.

(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

    //Add a new body/atlas sprite at the touched location 
    for(UITouch *touch in touches) { 
     CGPoint location = [touch locationInView: [touch view]]; 

     location = [[CCDirector sharedDirector] convertToGL: location]; 

     //[self addNewSpriteAtPosition: location]; 
     [_blade dim:YES]; 
     [_bladeSparkle stopSystem]; 

     for (b2Body* b = world->GetBodyList(); b; b = b->GetNext()) 
     { 

      if (b->GetUserData() != NULL) { 
       PolygonSprite *sprite = (PolygonSprite*)b->GetUserData(); 
       NSLog(@"sprite entered, exited %d, %d",sprite.sliceEntered,sprite.sliceExited); 
       if(sprite.type == kTypeTrapPrice && CGRectContainsPoint(sprite.boundingBox, location)) 
       { 
        NSLog(@"TOUCHED"); 


        noTouch++; 
       } 
      } 
     } 
    } 
    // NSLog(@"NO TOUCH %i",noTouch); 
    [self clearSlices]; 
} 
+1

실제로 어떻게됩니까? 왜 작동하지 않습니까? –

답변

관련 문제