【发布时间】:2011-09-21 22:51:41
【问题描述】:
我正在使用 box2d 在 xcode 中编写应用程序。现在我正在使用下面的代码。问题是它只会处理一个触摸事件。如何让我的代码处理所有触摸事件,在这种情况下检查每个触摸的位置。我还想存储触摸,以便当它们结束时,我可以使用正确的代码来结束个人触摸开始的任何内容。
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
CGSize screenSize = [CCDirector sharedDirector].winSize;
if (locationWorld.x >= screenSize.width*2/5/PTM_RATIO && locationWorld.x <= screenSize.width*3.25/5/PTM_RATIO) {
//do something
}
else if (0 && locationWorld.x <= screenSize.width*2/5/PTM_RATIO) {
//do something else
}
}
【问题讨论】:
标签: iphone xcode box2d multi-touch