sprite.play

Section: Sprite Animation

What it does

sprite.play acts on sprite: it plays. It takes id, fps, loop, fromFrame and toFrame. fps, loop, fromFrame and toFrame are optional.

Signature

sprite.play(id, fps?, loop?, fromFrame?, toFrame?)

Arguments

  • id
  • fpsoptional
  • loopoptional
  • fromFrameoptional
  • toFrameoptional

Example · generated

function start() {  const id = sprite.create('/sprites/hero.png', 100, 120);  sprite.play(id);}

sprite.create is there to give the call something to act on; sprite.play is the line that matters. The code sits in start(), which the engine calls once, when the entity spawns.

49 members in sprite