Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit) (+1)

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);

Is there a way to switch colors in Pixelbox like there is in Pico-8 with the pal() function?

There are not feature like Pico-8’s pal by default in Pixelbox.

This is probably achievable with a custom shader, but would require some extra preparation. If there are people interested, I could try to create a small demo to show how this can be done.

That would be great, thank you.

I added a new palette-swap-shader project to the Demo projects archive that can be downloaded from the Pixelbox page.

This project demonstrate how to use a shader filter to achieve a palette swap effect.

Note that it needs version 2.1.1 of the Pixelbox library. While creating this demo, I noticed few improvements that where required in the ShaderFilter component. This changes will be included later, in the next release of Pixelbox. I the meantime, you need to update the library by yourself using npm install.

Please let me know if you’re not familiar with NPM or if you have trouble installing the 2.1.1 version.