我有一个乒乓球比赛,我用手指移动桨。当有一根手指时,一切都很顺利。但是当我想控制两个玩家,两个桨时,一个桨移动得很好,但另一个桨移动很慢,如果有的话。当第二个桨开始移动时,我的第一个桨冻结。如何让两个动作都感觉流畅且反应灵敏?
我在我的 Director 中启用了多点触控。
这是我的触摸代码:
- (void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
CGRect leftTouchZone = CGRectMake(0, 0, 50, 320);
CGRect rightTouchZone = CGRectMake(430, 0, 50, 320);
if (CGRectContainsPoint(leftTouchZone, location))
{
CGPoint tempLoc = location;
tempLoc.x = paddle1.position.x;
paddle1.position = tempLoc;
}
if (CGRectContainsPoint(rightTouchZone, location))
{
CGPoint tempLoc = location;
tempLoc.x = paddle2.position.x;
paddle2.position = tempLoc;
}