简体   繁体   中英

SKAction display single image for duration?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM