sprite.setColor

Section: Sprite 2D

What it does

sprite.setColor sets Color on a sprite object. It takes id, r, g, b and a. a is optional.

Signature

sprite.setColor(id, r, g, b, a?)

Arguments

  • id
  • r
  • g
  • b
  • aoptional

Example · generated

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

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

49 members in sprite