如何从视图中完全删除SKAction

时间:2015-09-20 09:08:09

标签: sprite-kit skaction

所以我有一个你需要射击敌人的游戏。当触摸开始时,一颗子弹落在你的手指下,当触碰到它时 - 它向敌人射击。我用SKActions制作了它。它一直运作良好,直到比赛结束。我没有特殊的场景,它只是一个带按钮的节点。但是当它出现时,关于子弹和敌人的SKActions仍在触摸中运行。我希望在比赛结束时禁用它们,并且不知道该怎么做。例如,我创建的一个我这样的灌肠:

func addMiddleHeart() {
    middleheart = SKSpriteNode(imageNamed: "redh")
    middleheart.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMaxY(self.frame) + 100)
    middleheart.zPosition = 1
    middleheart.physicsBody = SKPhysicsBody(circleOfRadius: middleheart.size.width / 2)
    middleheart.physicsBody?.dynamic = true
    middleheart.physicsBody?.categoryBitMask = PhysicsCategory.MiddleHeart
    middleheart.physicsBody?.contactTestBitMask = PhysicsCategory.Arrow
    middleheart.physicsBody?.collisionBitMask = PhysicsCategory.None
    addChild(middleheart)

    let moveToPoint = SKAction.moveTo(CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame) + leftHeart.size.height * 1.5), duration: 0.5)
    SKActionTimingMode.EaseOut
    middleheart.runAction(moveToPoint)
}

      override func didMoveToView(view: SKView) {
 runAction(SKAction.runBlock(addMiddleHeart))
}

0 个答案:

没有答案