I have the following code to move an SKSpriteNode
.
let moveDown = SKAction.moveBy(CGVectorMake(0, -120), duration: 1)
let moveUp = SKAction.move
An alternative to @Whirlwind 's answer, in case you have a bunch of actions that need to be paused that are not in a group and not just the movement, is to just pause the node itself. All SKNodes have a paused
property associated with it.
Ex.
square.paused = true
SCNNode.paused has been renamed to SNCNode.isPaused.
You should be able to do the following
Pause animation:
square.isPause=true
Restart animation:
square.isPaused=false
You should run an action with key:
square.runAction(SKAction.repeatActionForever(moveSequence), withKey:"moving")
Then, use action's speed property to pause it:
if let action = square.actionForKey("moving") {
action.speed = 0
}
or to unpause it:
action.speed = 1