我正在使用 SpriteKit + Swift 制作一个简单的 Pong 游戏。这是一个多人游戏,所以我希望两个人能够移动两个桨。我希望能够同时移动桨。当我运行下面的代码时,即 touchesBegan 函数,我只能在一根手指按下显示屏时移动每个桨。当我尝试触摸另一个桨时,当我的手指已经在屏幕上时,它没有响应。
let touch = touches.first as UITouch?
let touchLocation = touch?.locationInNode(self)
let body: SKPhysicsBody? = self.physicsWorld.bodyAtPoint(touchLocation!)
if body?.node!.name == PaddleCategoryName {
print("Paddle Touched!")
fingerIsOnPaddle = true
} else if body?.node!.name == PaddleCategoryName2 {
print("Paddle2 Touched!")
fingerIsOnPaddle2 = true
}
最佳答案
我知道这有点晚了,但如果你仍然不知道答案,我相信你需要在加载第一个场景时在 viewController 中设置这一行
skView.multipleTouchEnabled = true
关于ios - 在 SpriteKit + Swift 中同时移动两个桨,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33194394/