0
我该如何做到这一点,以便当用户在操纵杆上玩中移动角色时,他们也可以触摸屏幕的右下角(第二次触摸)来开枪?我已经看了看其他的问题,但我仍然无法弄清楚......iPhone上的多点触控问题
这是基本的代码....:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//make the touch point...
UITouch *touch = [[event allTouches]anyObject];
CGPoint point = [touch locationInView:touch.view];
if (//touching a certain area (on the joystick)) {
//do stuff
}
else if (point.x > 300 && point.y > 200) {
/fire method
}
}
所以基本上我怎么叫的touchesBegan再次找到位置CGPoint要点,如果应该调用fire方法,就研究一下吧?
感谢
编辑:
我试图做的是第二个选项,并做到了这一点:我添加 鉴于或者Controller.h:
@interface fireView: UIView
@end
在.M我说:
@implementation fireView -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"hi");
}
@end
....但它不记录/打印“嗨”?
我如何使用它? – Bob
对于游戏而言,UIGestureRecognizer引入的滞后真的很麻烦。我会建议你的方法,但要继承两个UIViews并使用touchesBegan – Mazyod
是的。这样更好。 –