我已經做了一個應用程序,我想讓它多點觸控兼容。我試過四處尋找,但答案並不是特定於我的。 這裏是我做的:如何使多點觸控啓用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;
}
}
}
2)我已經到界面生成器和檢查多點觸控啓用
3盒)我建立並運行我的應用程序並打開正確,當我去測試多點觸控我按住「選項鍵」,然後點擊並移動鼠標
4)(我正在試圖讓computerPaddle和playerPaddle都移動),但只有一個作品在時間
我必須嘗試解決它,但我不明白我要去哪裏錯了。
任何幫助都很有用。 THX。
我認爲你有正確的想法,但xlc0212給了編碼。無論如何 – burkel