sprite(spr: string | SpriteData | Asset, opt?: SpriteCompOpt): SpriteComp

Attach and render a sprite to a Game Object.

paramspr- The sprite to render.

paramopt- Options for the sprite component. See

// minimal setup
add([
    sprite("bean"),
])

// with options
const bean = add([
    sprite("bean", {
        // start with animation "idle"
        anim: "idle",
    }),
])

// play / stop an anim
bean.play("jump")
bean.stop()

// manually setting a frame
bean.frame = 3

returnsThe sprite comp.

sincev2000.0