这是我的小情况。我正在使用uipanGesture移动一个ccsprite。我可以将它全部移到没有问题的位置,并且我可以使用uitapgesture拍摄屏幕上的一个点。UIPanGestureRecognizer和UITapGestureRecognizer同时
-(void)handleTap:(UITapGestureRecognizer *)recognizer{
CGPoint location = [recognizer locationInView:recognizer.view];
location = [[CCDirector sharedDirector]convertToGL:location];
location = [self convertToNodeSpace:location];
if (location.x > winSize.width * .6 && location.y <winSize.height/2) {
NSLog(@"fire");
}
我添加了委托方法,所以当我平移时,我可以点击fire按钮:一切正常。
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES;
}
但是,当我不平移和只使用uitapgesture射击,当我烧我无法平移...我认为这正在发生的原因是因为它的注册最后自来水作为 recognizer.state == UIGestureRecognizerStateBegan
自我不是在摇摆。
任何人知道一种方法,我可以挖掘,而不是注册水龙头作为if (recognizer.state == UIGestureRecognizerStateBegan
如果(location.x < winSize.width/2)
,但它没有工作,我试过。
我们可以看到你创建的手势? –
我在这个例子中创建了两个地方,我在init中创建了它,但是我之前在应用程序委托中创建了它们。 – ifrapps