화면을 터치하면 계속 이동하고 터치를 놓으면 중지합니다. 나는 box2d와 cocos2d를 사용하고 있는데, 왜 내 코드가 잘 수행되지 않는지 잘 모릅니다. 내가 스프라이트 몸의 움직임본문 화면을 터치하면 연속 이동합니다
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
ccTime dt;
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
location=[[CCDirector sharedDirector]convertToGL:location];
[self moveRight:dt];
// [self doWhateverYouWantToDo];
// [self doItWithATouch:touch];
}
-(void)moveRight:(ccTime)dt
{
CCSprite *ballright=(CCSprite *)ballbody->GetUserData();
NSLog(@"Ball PositionX: %f",ballbody->GetPosition().x);
NSLog(@"Ball PositionY: %f",ballbody->GetPosition().y);
[ballright runAction:[CCMoveTo actionWithDuration:1 position:ccp(ballbody->GetPosition().x,ballbody->GetPosition().y+5*dt)]];
}
나 논리와 코드 나를 제발 도와주세요 쓰기 알려 주시기 바랍니다보다 그렇다면 그 잘못에 대한 사용 touchesBegan.
감사합니다.
작동하지만 화면을 터치하면 움직이고 해제 후에는 중지되지만 다음 시간 이후에는 탭 화면이 작동하지 않습니다. –