2014-09-07 2 views
0

내 장면에서 서로 다른 방향으로 이동하려는 두 개의 스프라이트가 있습니다. 나는 주변에서 검색하는 다음 방법을 시도했지만 아무것도 작동시킬 수 없습니다. 이것은 내가 지금까지 가지고있는 최고입니다. 누구나 손을 빌려 준다면 위대 할 것입니다.Cocos2d/spritebuilder에서 두 개의 CCSprites 이동

-(void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event 
{ 
CGPoint touchLocation = [touch locationInNode:self]; 
if(CGRectContainsPoint([redLeash boundingBox], touchLocation)) 
{ 
redLeash.position = touchLocation; 
} 
else if 
(CGRectContainsPoint([blueLeash boundingBox], touchLocation)) 
{ 
blueLeash.position = touchLocation; 
} 
} 

답변

0

시도해보십시오. 여기에 입력하여 구문 오류가있을 수 있지만 작동해야합니다.

-(void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event 
{ 
    CGPoint touchLocation = [touch locationInNode:self]; 

    if(CGRectContainsPoint([redLeash boundingBox], touchLocaiton)) 
    { 
     [redLeash setPosition:touchlocation]; 
    } 
    else if (CGRectContainsPoint([blueLeash boundingBox], touchLocation)) 
    { 
     [blueLeash setPosition:touchLocation]; 
    } 
    } 
+0

답장을 보내 주셔서 감사합니다. 행운을 빌어 요. – user2800989