# Animation Player

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

```
component animation.AnimationPlayer
```

Plays an animation clip on its node and the nodes below it: property tracks, sprite frames and events. Clip time, gameplay events and tracks other than the transform pose advance on fixed steps, so a replay gives the same result at any frame rate.

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Clip | `Clip` | `AnimClip` | `none` | Clip to play. |
| Play On Start | `PlayOnStart` | `bool` | `true` | Starts the clip when Play starts. |
| Speed | `Speed` | `float` | `1` | Playback speed: 1 is normal, 2 twice as fast; a negative speed plays backwards. |
| Loop | `Loop` | `enum` | `clip` | clip keeps the loop mode of the clip; once, loop and pingPong override it. |
| Time Domain | `TimeDomain` | `enum` | `game` | game follows game time and pauses with it; unscaled runs in real time while paused, for menus and other presentation. |
| Time | `Time` | `float` | `0` | Runtime state. Time inside the clip, in seconds. |
| Playing | `Playing` | `bool` | `false` | Runtime state. Whether the clip plays. |
| Cycle | `Cycle` | `int` | `0` | Runtime state. Cycles of a looping clip so far. |

## Pause

```
func (AnimationPlayer) Pause()
```

Holds the clip where it is.

## Play

```
func (AnimationPlayer) Play(clip AssetRef<anim>)
```

Starts a clip from its beginning on the next fixed step; nil plays the current clip again.

## Resume

```
func (AnimationPlayer) Resume()
```

Continues a paused clip.

## Seek

```
func (AnimationPlayer) Seek(time float)
```

Jumps to a time inside the clip on the next fixed step without firing the events in between.

## SetSpeed

```
func (AnimationPlayer) SetSpeed(speed float)
```

Changes the playback speed; a negative speed plays backwards.

## Stop

```
func (AnimationPlayer) Stop()
```

Ends the clip on the next fixed step: tracks with onEnd=restore get back the values they had before Play, Finished runs with cycle -1.

## Event

```
signal Event(id int, payload float)
```

Runs when the clip reaches an event; anim.EventName(id) gives its name.

## Finished

```
signal Finished(cycle int)
```

Runs when a clip that does not loop ends, with cycle 0, or after Stop, with cycle -1.
