# SpriteAnimationEndEvent

> Talos next · Since 0.6

`data` of the event a non-looping sprite animation raises when it ends.

## Signature

```ts
export interface SpriteAnimationEndEvent {
  /** Id of the entity whose sprite it was. */
  entity: string
  /** The animation that ended. */
  animation: string
  /** The animation that took over (`then`), or null. */
  next: string | null
}
```

Import: `import type { SpriteAnimationEndEvent } from "@argus/api"`

## Members

| Member | Signature | Description |
|---|---|---|
| `entity` | `entity: string` | Id of the entity whose sprite it was. |
| `animation` | `animation: string` | The animation that ended. |
| `next` | `next: string \| null` | The animation that took over (`then`), or null. |

## Example

The tested fixture `fixtures/recipes/drone-search/scenes/behaviors/carrier.ts`.

```ts
import type { Behavior } from "@argus/api"

/** Moves a kinematic body round `props.path` (world [x, z] points) at `props.speed` m/s, facing where it goes: the
 * stand-in for a boat or a truck the drone launches from, and for the contact it looks for. */
interface Props {
  path: [number, number][]
  speed: number
}

interface State {
  next: number
}

export default {
  init(ctx) {
    ctx.state.next ??= 0
  },
  update(ctx, dt) {
    const path = ctx.props.path
    const goal = path[ctx.state.next % path.length]
    if (goal === undefined) return
    const p = ctx.entity.position
    const to: [number, number, number] = [goal[0], p[1], goal[1]]
    ctx.entity.lookAt(to)
    if (ctx.entity.moveToward(to, ctx.props.speed * dt)) ctx.state.next = (ctx.state.next + 1) % path.length
  },
} satisfies Behavior<State, Props>
```
