animate(with:timePerFrame:resize:restore:)
Creates an action that animates changes to a sprite’s texture, possibly resizing the sprite.
Declaration
class func animate(with textures: [SKTexture], timePerFrame sec: TimeInterval, resize: Bool, restore: Bool) -> SKActionParameters
- textures:
An array of textures to use when animating a sprite.
- sec:
The amount of time, in seconds, that each texture is displayed.
- resize:
If True, the sprite is resized to match each new texture. If False, the size of the sprite remains at a constant size.
- restore:
If True:
When the action completes, the sprite’s texture is restored to the texture it had before the action completed. (If the resize parameter is True, the sprite is resized to match the size of the original texture.)
If False:
When the action completes, the sprite’s texture remains set to the final texture in the array.
Return Value
A new action object.
Discussion
This action can only be executed by an SKSpriteNode object. When the action executes, the sprite’s texture property animates through the array of textures. The sprite’s texture property is changed to the next texture in the array. The action then pauses for the specified time before continuing. The action continues until it has finished animating through all of the textures in the array. The total duration of the action is the number of textures multiplied by the frame interval.
This action is reversible; the resulting action animates through the same textures from last to first.
See Also
Animating a Node’s Texture
resize(byWidth:height:duration:)resize(toHeight:duration:)resize(toWidth:duration:)resize(toWidth:height:duration:)setTexture(_:)setTexture(_:resize:)animate(with:timePerFrame:)setNormalTexture(_:)setNormalTexture(_:resize:)animate(withNormalTextures:timePerFrame:)animate(withNormalTextures:timePerFrame:resize:restore:)colorize(with:colorBlendFactor:duration:)colorize(withColorBlendFactor:duration:)