sprite.clone

Section: Sprite 2D

What it does

sprite.clone brings a sprite object into being: it is how the rest of the script comes to have one. It takes srcId.

Signature

sprite.clone(srcId)

Arguments

  • srcId

Example · generated

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

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

49 members in sprite