【发布时间】:2011-09-29 22:26:34
【问题描述】:
我正在尝试制作一个简单的横向“分屏”应用程序,其中两个玩家可以同时玩(每个玩家占据屏幕的一半),但我无法同时跟踪两个触摸。这是我尝试使用的代码:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
CGPoint point = [touch locationInView:self.view];
if (point.x < 240) {
[player1 updatePoint:point];
} else {
[player2 updatePoint:point];
}
}
}
但我显然做错了什么。尽管此代码运行良好,但它只会跟踪一根手指并将玩家移动到手指所在的屏幕一侧。我的代码缺少什么?这个任务是不是比我想象的更难完成?
【问题讨论】:
标签: iphone objective-c