我正在用SpriteKit + Swift做一个简单的乒乓球游戏。这是一个多人游戏,所以我希望两个人能够移动两个球拍。我希望能够同时移动球拍。当我运行下面的代码时,这是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
}
发布于 2015-12-07 15:25:14
我知道这有点晚了,但是如果你仍然不知道答案,我相信你需要在加载第一个场景时在你的viewController中设置这一行
skView.multipleTouchEnabled = true
https://stackoverflow.com/questions/33194394
复制相似问题