如何使多点触控启用ios应用程序

bur*_*kel 1 iphone cocoa-touch multi-touch ios

我做了一个应用程序,我想让它与多点触控兼容.我试过环顾四周,但答案并不是我特有的.这是我做的:

1)我的编码:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

[self touchesMoved:touches withEvent:event];
if (gameState == kGameStatePaused) {(gameState = kGameStateRunning);}
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if(gameState == kGameStateRunning) {

    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    if(location.x > 400) {

        CGPoint yLocation = CGPointMake(playerPaddle.center.x, location.y);
        playerPaddle.center = yLocation;
    }

    if (gameStyle == kGameStyleTwoP) {
        if(location.x < 100) {

            CGPoint yLocation2 = CGPointMake(computerPaddle.center.x, location.y);
            computerPaddle.center = yLocation2;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

2)我已经进入Interface Builder并选中了启用多点触控的方框

3)我构建并运行我的应用程序,它打开正常,当我去测试多点触控我拿着"选项键",然后单击并移动鼠标

4)(我试图让computerPaddle和playerPaddle都移动)但是一次只能做一件作品

我必须尝试解决它,但我无法理解我哪里出错了.

任何帮助都很有用.谢谢.

J_D*_*J_D 10

multipleTouchEnabled 在UIView上有一个名为的属性,您可以设置为YES以启用它(默认为NO).

此外,您应该循环处理touches您收到的集合中的所有触摸touchesMoved.