我已经创建了一个容器节点,将所有需要在一次触摸中移动的SKSpriteNodes放入其中,我可以正常地在iOS 8上检测到它们的触摸,但是在iOS 7上,我只能检测到主节点上的触摸,当我触摸容器节点中的SKSpriteNode时,什么也没有发生。如何解决这个问题?
let lvlsNode = SKNode()
override func didMoveToView(view: SKView) {
self.addChild(lvlsNode)
axe = SKSpriteNode(imageNamed:"axe")
axe.anchorPoint = CGPointMake(1, 0)
axe.size = CGSizeMake(axe.size.width/1.4, axe.size.height/1.4)
axe.position = CGPointMake(0+screenWidth/7, shield.position.y-shield.size.width*1.4)
axe.zPosition = 12
axe.name = "axe"
lvlsNode.addChild(axe)
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch in (touches as! Set<UITouch>) {
let location = touch.locationInNode(self)
let node = nodeAtPoint(location)
if node.name == "axe" {
// do something.... this work in iOS8 but not in iOS 7.1
}