1

I am making a game using Xcode Swift SpriteKit where a character is running, and then when the character is told to jump, it moves up and stops animating, and resumes animating when it hits the ground. I have the following code but I am not sure what to do to rerun the animation.

Here is my code for starting the animation:

var BigLeftTexture1 = SKTexture(imageNamed: "Ninja Pro 1")
var BigLeftTexture2 = SKTexture(imageNamed: "Ninja Pro 2")
var BigLeftTexture3 = SKTexture(imageNamed: "Ninja Pro 3")
var BigLeftTexture4 = SKTexture(imageNamed: "Ninja Pro 4")
var BigLeftTexture5 = SKTexture(imageNamed: "Ninja Pro 5")
var BigLeftTexture6 = SKTexture(imageNamed: "Ninja Pro 6")
BigPerson = SKSpriteNode(imageNamed: "Ninja Pro 4")

var leftanimation1 = SKAction.animateWithTextures([BigLeftTexture1, BigLeftTexture2, BigLeftTexture3, BigLeftTexture4, BigLeftTexture5, BigLeftTexture6], timePerFrame: 0.065)
var LeftSideRunning = SKAction.repeatActionForever(leftanimation1)
BigPerson.runAction(LeftSideRunning, withKey: "BigStopLeftSide")

Here is my code for stopping the animation:

BigPerson.removeActionForKey("BigStopLeftSide")

2
  • 1
    What exactly is the problem you are experiencing Commented Mar 7, 2015 at 17:35
  • I am trying to pause the animation and resume it when it is done moving, however it does not seem to work. Commented Mar 11, 2015 at 22:43

1 Answer 1

0

Try

// to stop the action
BigPerson.paused = true

// to move on
BigPerson.paused = false
Sign up to request clarification or add additional context in comments.

2 Comments

If the goal is to pause a certain action, then you don't need to pause the whole node. You can just pause that action.
Hi Whirlwind, how would you do that? With .Speed = 0?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.