如何从视图中完全删除 SKAction

How to completely remove SKAction from the view

所以我有一个游戏,你需要射击敌人。当 touchesBegan 时,一颗子弹就在你的手指下,当 touchesEnded 时——它向敌人开火。我用 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))
}

gameScene.removeAllActions() 是您要使用的语句。它会不分青红皂白地删除所有 运行 SKActions.