Talos docs

SpritePlayOptions

Since 0.6

How an animation started by {@link Sprite.play} ends.

Plain text

Signature

export interface SpritePlayOptions {
  /** The animation that takes over when a non-looping one ends. Default: none, it holds its last frame. */
  then?: string
  /** The bus event raised when a non-looping one ends. Default `"animation-end"`. */
  event?: string
  /** Start over when it is the animation already playing. Default false: it runs on. */
  restart?: boolean
}

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

Members

MemberSignatureDescription
thenthen?: stringThe animation that takes over when a non-looping one ends. Default: none, it holds its last frame.
eventevent?: stringThe bus event raised when a non-looping one ends. Default "animation-end".
restartrestart?: booleanStart over when it is the animation already playing. Default false: it runs on.

Example

The tested fixture fixtures/app/agent.ts.

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

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior