나는 UIGestureRecognizers
과 SKScene/SKNode's
을 SpriteKit
으로 실험하고 있습니다. 한 가지 문제가 있었지만 해결하기가 어려웠지만 한 가지를 혼란스럽게합니다. 필자는 사용자가 화면에 스프라이트를 끌 수있는 팬 제스처 인식기를 가지고 있습니다.SKScene의 UIPanGestureRecognizer
내가 가진 하나의 문제는 제대로 작동에 만 두 번째로 두 드릴 후 실제로 팬 제스처를 초기화 ONE 탭을 소요하고 있다는 점이다. 내 팬 제스처가 touchesBegan
에서 초기화되기 때문이라고 생각하고 있어요. 그러나, 나는 실제로 작업에서 SKScene의 initWithSize
방법에 제스처 인식기를 멈췄다 초기화 이후 넣어 위치를 다른 모른다. 화면이 적어도 한 번 탭 때까지 제스처가 존재하지 않는 있도록 터치의 제스처를 추가하고 있기 때문이다
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (!self.pan) {
self.pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(dragPlayer:)];
self.pan.minimumNumberOfTouches = 1;
self.pan.delegate = self;
[self.view addGestureRecognizer:self.pan];
}
}
-(void)dragPlayer: (UIPanGestureRecognizer *)gesture {
CGPoint trans = [gesture translationInView:self.view];
SKAction *moveAction = [SKAction moveByX:trans.x y:-trans.y duration:0];
[self.player runAction:move];
[gesture setTranslation:CGPointMake(0, 0) inView:self.view];
}