<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKAction/animate(with:timePerFrame:resize:restore:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKAction(cm)animateWithTextures:timePerFrame:resize:restore:"
  },
  "title" : "animate(with:timePerFrame:resize:restore:)"
}
-->

# animate(with:timePerFrame:resize:restore:)

Creates an action that animates changes to a sprite’s texture, possibly resizing the sprite.

```
class func animate(with textures: [SKTexture], timePerFrame sec: TimeInterval, resize: Bool, restore: Bool) -> SKAction
```

## Parameters

`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 <doc://com.apple.documentation/documentation/Swift/true>, the sprite is resized to match each new texture. If <doc://com.apple.documentation/documentation/Swift/false>, the size of the sprite remains at a constant size.

`restore`

- If <doc://com.apple.documentation/documentation/Swift/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     <doc://com.apple.documentation/documentation/Swift/true>    , the sprite is resized to match the size of the original texture.)

- If <doc://com.apple.documentation/documentation/Swift/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`](/documentation/SpriteKit/SKSpriteNode) object. When the action executes, the sprite’s [`texture`](/documentation/SpriteKit/SKSpriteNode/texture) property animates through the array of textures. The sprite’s [`texture`](/documentation/SpriteKit/SKSpriteNode/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.

> Note:
> If the `restore` parameter is <doc://com.apple.documentation/documentation/Swift/true> and this action is removed from a node before it completes, then node’s texture is still restored. This differs from the default behavior of removing an action.

This action is reversible; the resulting action animates through the same textures from last to first.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)