【发布时间】:2015-10-24 08:25:13
【问题描述】:
我正在制作一个通用的 SpriteKit 游戏。我在 iPhone 和 iPad 上测试我的游戏。在 iPhone 中一切正常,在模拟器中也是如此,但在 iPad 中,触摸功能在游戏场景中无法正常工作。例如;在游戏场景中,我有 4 个精灵,我可以触摸其中一个,但其他精灵在 iPad 中不起作用。有什么想法吗?到底是怎么回事 ?
for touch in touches {
let location = touch.locationInNode(self)
for var i=1; i<ballNode.count; i++ {
if nodeAtPoint(location) == ballNode[i].node && !ballNode[i].character.locked {
ballNode[i].touchingNode = true
ballNode[i].angelLabel.hidden = false
let seq = SKAction.sequence([fadeIn, fadeOut])
ballNode[i].node.childNodeWithName("laserAni")!.hidden = false
ballNode[i].node.childNodeWithName("laserAni")!.runAction(SKAction.repeatActionForever(seq))
if ballNode[i].node.name == BallTypes.multipleGuns {
ballNode[i].node.childNodeWithName("laserAni2")!.hidden = false
ballNode[i].node.childNodeWithName("laserAni2")!.runAction(SKAction.repeatActionForever(seq))
}
}
}
【问题讨论】:
-
你用来“触摸”它们的代码是什么?
-
In touch started function I use if nodeAtPoint(location) == node {// code here }
-
你能发布代码吗?代码不应仅仅因为您使用的是 iPad 而无法工作
-
是的,我无法理解,代码在 İphone 上完美运行,但在 iPad 上却不行?你想看哪一部分?
-
您的
touches方法或任何其他处理触摸事件的部分
标签: ios swift sprite-kit touch universal