2
스 와이프를 설정하여 작업을 수행 할 때 몇 가지 문제가 있습니다. 아래 코드를 사용하려고하지만 터치를 인식하지 못합니다.Cocos2d iPhone v3.0 - 스 와이프하여 작업 수행
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
UITouch * touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
//Swipe Detection Part 1
firstTouch = location;
CCLOG(@"touched");
}
-(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
UITouch * touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
//Swipe Detection Part 2
lastTouch = location;
//Minimum length of the swipe
float swipeLength = ccpDistance(firstTouch, lastTouch);
CCActionJumpTo *jump1 = [CCActionJumpTo actionWithDuration:2 position:ccp(self.contentSize.width*.4,self.contentSize.height*.1) height:self.contentSize.height*.5 jumps:1];
[_fufunaken runAction:[CCActionRepeat actionWithAction:jump1 times:1]];
//Check if the swipe is an up swipe and long enough
if (firstTouch.y > lastTouch.y && swipeLength > 60) {
[_fufunaken runAction:[CCActionRepeatForever actionWithAction:jump1]];
}
}
화면을 터치 할 때 '터치'라고 말하지 않고 init에서 사용자 상호 작용을 사용하도록 설정했습니다. 어떤 도움을 받게 될 것입니다! 당신이 좋은 소식은 당신이 단순히 다음 줄
CGPoint touchPos = [touch locationInNode:self];
을 모두 사용하여 터치의 현재 위치를 얻을 수있는 모든 ccTouchesBegan/ccTouchesMoved/ccTouchesEnded
-(void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
-(void) touchMoved:(UITouch *)touch withEvent:(UIEvent *)event
-(void) touchEnded:(UITouch *)touch withEvent:(UIEvent *)event
에 교체 할 필요가 v3으로적인 Cocos2D에서
당신은 남자입니다. –
@ C__ESP 기꺼이 도와 드리겠습니다! :) –