sprite.getCurrentFrame

Section: Sprite Animation

What it does

sprite.getCurrentFrame reads CurrentFrame on a sprite object. It takes id.

Signature

sprite.getCurrentFrame(id)

Arguments

  • id

Example · generated

function update(dt) {  const id = sprite.create('/sprites/hero.png', 100, 120);  const currentFrame = sprite.getCurrentFrame(id);}

sprite.create is there to give the call something to act on; sprite.getCurrentFrame is the line that matters. The code sits in update(dt), which the engine calls every frame: dt is the time since the last one, in seconds.

49 members in sprite