Question

SKAction *ghostAnimationAction = 
[SKAction animateWithTextures:ghostFrames timePerFrame:0.1];

SKAction *ghostDelayAction = 
[SKAction animateWithTextures:@[[SKTexture textureWithImageNamed:@"Ghost_"]]     
timePerFrame:1.0];

SKAction *ghostAnimationSequence = 
[SKAction sequence:@[ghostAnimationAction, ghostDelayAction]];

SKAction *repeatGhostAnimationSequence = 
[SKAction repeatActionForever:ghostAnimationSequence];

I have an animated sequence of frames which is made up of an NSMutableArray of SKTexture objects. Once that sequence has played I want to fold on a still frame for a second before repeating everything. The code above works, but the only way I can find to specify holding on a frame for a duration is to use animateWithTextures:timePerFrame: and supply a single texture array. Is there another way to get an SKAction to display a single image for a duration that I am missing.

Était-ce utile?

La solution

You could create a new SKAction that encloses both of these two actions. See the Sprite Kit Programming Guide section called 'Creating Actions That Run Other Actions' here Adding Actions To Nodes

Take a look at the SKAction member waitForDuration: too, you may be able to avoid passing in the single texture that way. Have the first SKAction run your animation, then have the second SKAction waitForDuration. Then your enclosing SKAction runs through these two actions forever or as long as needed.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top