Mugs
Mugs

Reputation: 339

How to continuously loop SKSprite Node using SKAction

On apples documentation, it says in the sub-heading of the article:

"Load a sequence of images and play them back at a rate you define, while optionally looping the resulting animation."

then provides this code as an example

let walkAnimation = SKAction.animate(with: monsterWalkTextures,
                                 timePerFrame: 0.1)

node.run(walkAnimation)
// insert other code here to move the monster.

But never shows how to optionally loop the animation?? One I would love to know how to loop the animation. But more importantly I would LOVE to be able to find all the details about the language in the documentation like it is for other languages. Can someone please tell me where I can find this mystical documentation that goes into more detail then an "overview" that leaves out the syntax for optional looping -.-

Upvotes: 1

Views: 118

Answers (1)

paulRick
paulRick

Reputation: 604

Here we can see all of SKAction.animate inits and I can't see none with an option to loop by itself. Now, I don't know if by "while optionally looping the resulting animation" they mean that when we have the SKAction instance returned from .animate we can put it in a .runForever:

let animation = SKAction.repeatForever(.animate(with: textures, timePerFrame: 0.3, resize: true, restore: false))
run(animation)

I agree with you, if they are putting this piece in the sub-head the least they can do is provide some basic example.

Upvotes: 1

Related Questions