sprite.create

Section: Sprite 2D

What it does

sprite.create brings a sprite object into being: it is how the rest of the script comes to have one. It takes imageUrl, x and y, and answers id. imageUrl, x and y are optional.

Signature

sprite.create(imageUrl?, x?, y?) → id

Arguments

  • imageUrloptional
  • xoptional
  • yoptional

Example · generated

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

sprite.create is called with values of the shape its signature asks for. The code sits in start(), which the engine calls once, when the entity spawns.

49 members in sprite