Contents

SampledAnimation

An animation that cycles through a series of frames at a constant interval.

Declaration

struct SampledAnimation<Value> where Value : AnimatableData

Overview

To specify the data that the animation samples, set one of the frames properties that matches the animated property’s type. For example, set the frames property to interpolate Float values.

The following code designates a SampledAnimation to animate a propery of type Float by specifying the generic typed syntax. The code queues an array of values: 1.0, 2.0, and 3.0.

// Define the animation type.
typealias SampledAnimationType = SampledAnimation<Float>

// Define the animated property values.
let frameArray: [Float] = [1.0, 2.0, 3.0]

To determine how fast the animation progresses from frame to frame, define this structure’s frameInterval property. The following code specifies a one-second delay between value changes before initializing the animation object.

// Define a one-second frame interval.
let interval: TimeInterval = 1

// Create the animation.
let sampleAnim = SampledAnimationType(
    frames: frameArray,
    name: "sampledAnim1",
    frameInterval: interval
    isAdditive: true,
    bindTarget: .transform,
    blendLayer: 100,
    repeatMode: .autoReverse,
    fillMode: .backwards,
    trimStart: 1.0,
    trimEnd: 10.0,
    trimDuration: 9.0,
    offset: 2.0,
    delay: 1.0,
    speed: 2.0
)

Topics

Creating an animation

Configuring the animation

Defining frames data

Timing the animation

Repeating animation playback

Initializers

Instance Properties

See Also

Animation definitions