The problem is that the variable palette
has not been defined (same problem for the variable tilesheet
. instead you can use assets.tilesheet
).
Pixelbox will alway initialize a texture with the default tilesheet and palette defined for the project. So you don’t need to use setPalette
unless you want to switch to a custom palette.
The palette must be an array of Color instances. Color can be initialized from a color string, or from its {red, blue, green} values.
The code would look something like this:
var Color = require('pixelbox/Color');
var palette = [
new Color().fromString('#001e14'),
new Color().fromString('#ff0035'),
new Color().fromRGB(0, 140, 255),
new Color().fromRGB(255, 255, 255),
];
texture.setPalette(palette);