Talos docs

SpriteAnimationEndEvent

Since 0.6

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

Plain text

Signature

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

MemberSignatureDescription
entityentity: stringId of the entity whose sprite it was.
animationanimation: stringThe animation that ended.
nextnext: string | nullThe animation that took over (then), or null.

Example

The tested fixture fixtures/host/door.ts.

import type { Behavior } from "@argus/api"
// docs/API.md, "Joints": a door on a hinge that swings open while the player is near and closes
// behind them. Typechecked by packages/api's tests.
export default {
  update(ctx) {
    const player = ctx.world.find("player")
    const near = player !== null && ctx.entity.distanceTo(player) < 2
    ctx.joint?.setMotor(near ? Math.PI / 2 : 0, { mode: "position", maxForce: 200 })
  },
} satisfies Behavior