0
我有一個pong遊戲,我用手指移動槳。有一根手指時,一切順利。但是當我想要控制兩名選手,兩名選手時,一名選手的動作很好,但另一名選手動作非常遲緩。當第二個槳開始移動時,我的第一個槳停止。我該如何讓這兩種動作順暢且反應靈敏?多點觸控和ccTouchesMoved,laggy移動
我在我的導演中啓用了多點觸控功能。
這裏是我的觸動代碼:
- (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;
}
工作!非常感謝! – Dvole 2012-08-05 16:16:23