나는 한 번에 두 인물로 움직이는 게임을 만들고있다. 각각 하나는 화면의 절반을 가지고 있으며 안으로 들어가서 움직입니다. 불행히도 나는 한 번에 두 엄지 손가락으로 쓸어 넘기면 아무 일도 일어나지 않는다는 것을 알았습니다. 내 인식기 중 하나도 실행되지 않습니다.시뮬레이트적인 독립적 인 제스처
어쩌면 편도가 있습니다. GameViewController 상단에 또 다른 두 가지 뷰를 만들고 별도의 제스처를 추가했습니다. 그러나 나는 게임을 통해 그들에게 행동을하기를 거부합니다.
GameScene에서 GameScController에서 선언 한 스 와이프를 인식하고 액션을 추가 할 수 있습니까?
나는 터치에 따라 이미 인식기를 만들려고 노력했지만 두 손가락이 한꺼번에 풀려 나올 때마다 지저분 해지고 대개 두 번 반응하는 것을 잊어 버렸다.
-(void)setUpGestActions{
_swipeGestureLeft = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft:)];
[self.swipeGestureLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
self.swipeGestureLeft.cancelsTouchesInView = NO;
self.swipeGestureLeft.delegate = self;
[self.view addGestureRecognizer: self.swipeGestureLeft];
_swipeGestureRight = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeRight:)];
[self.swipeGestureRight setDirection:UISwipeGestureRecognizerDirectionRight];
self.swipeGestureRight.cancelsTouchesInView = NO;
self.swipeGestureRight.delegate = self;
[self.view addGestureRecognizer: self.swipeGestureRight];
_swipeGestureUp = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeUp:)];
[self.swipeGestureUp setDirection:UISwipeGestureRecognizerDirectionUp];
self.swipeGestureUp.cancelsTouchesInView = NO;
self.swipeGestureUp.delegate = self;
[self.view addGestureRecognizer: self.swipeGestureUp];
_swipeGestureDown = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeDown:)];
[self.swipeGestureDown setDirection:UISwipeGestureRecognizerDirectionDown];
self.swipeGestureDown.cancelsTouchesInView = NO;
self.swipeGestureDown.delegate = self;
[self.view addGestureRecognizer: self.swipeGestureDown];
_moveLeft = [SKAction moveByX:-self.frame.size.width/6 y:0 duration:self.velocity];
_moveRight = [SKAction moveByX:self.frame.size.width/6 y:0 duration:self.velocity];
_moveUp = [SKAction moveByX:0 y:self.frame.size.width/6 duration:self.velocity];
_moveDown = [SKAction moveByX:0 y:-self.frame.size.width/6 duration:self.velocity];
_downMovement = [SKAction moveByX:0 y:-1 duration:self.downMovementVelocity];
}
-(void)swipeLeft:(UISwipeGestureRecognizer*) recognizer{
_sideDisting = [recognizer locationInView:self.view];
if(self.sideDisting.x <= self.frame.size.width/2){
[_boy runAction:self.moveLeft];
}
else{
[_girl runAction:self.moveLeft];
}
}
-(void)swipeRight:(UISwipeGestureRecognizer*) recognizer{
_sideDisting = [recognizer locationInView:self.view];
if(self.sideDisting.x <= self.frame.size.width/2){
[_boy runAction:self.moveRight];
}
else{
[_girl runAction:self.moveRight];
}
}
-(void)swipeUp:(UISwipeGestureRecognizer*) recognizer{
_sideDisting = [recognizer locationInView:self.view];
if(self.sideDisting.x <= self.frame.size.width/2){
[_boy runAction:self.moveUp];
}
else{
[_girl runAction:self.moveUp];
}
}
-(void)swipeDown:(UISwipeGestureRecognizer*) recognizer{
_sideDisting = [recognizer locationInView:self.view];
if(self.sideDisting.x <= self.frame.size.width/2){
[_boy runAction:self.moveDown];
}
else{
[_girl runAction:self.moveDown];
}
}
나는 이미이 작업을 수행했지만 아무런 결과가 없습니다. interface 및 bool의 델리게이트를 YES로 설정하면 self.swipeGestureDown.delegate = self; alloc 코드의 각 블록에있는 행. 더블 슬쩍이나 뭔가 다른 인식기와 혼동을 일으킬 수 있습니다. (나는 내 코드에서 그런 것을 선언하지 않았다) –