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")

ndmeiri
  • 4,979
  • 12
  • 37
  • 45
Skiddyflyer
  • 213
  • 1
  • 2
  • 8

1 Answers1

0

Try

// to stop the action
BigPerson.paused = true

// to move on
BigPerson.paused = false
ndmeiri
  • 4,979
  • 12
  • 37
  • 45
aignetti
  • 481
  • 1
  • 3
  • 14