Learn how to color your tiles - AnselmeClergeot/FisoEngine GitHub Wiki

Let's color our tiles !

To decorate your map, coloring tiles may be useful. Let's learn how to do this.

1) The Color class

To define a color, you will need to use the fe::Color class. It is extremely simple: it contains 4 integers:

  • r which represents the red color value (value from 0 to 255)
  • g which represents the green color value (value from 0 to 255)
  • b which represents the blue color value (value from 0 to 255)
  • a which represents the opacity value (value from 0 to 255)

Some examples showing how to use a Color:

fe::Color(255, 0, 255, 255);
someFunction(fe::Color(23, 158, 128));
//etc.

You can also use already-prepared colors by doing fe::Color::Blue, fe::Color::Yellow, etc.

For the precise Color documentation, see the doc.

2) Coloring a simple tile

To set the color of a single tile, use:

myMap.setTileColor(your3DCoordinates, yourColor);
3) Coloring all tiles of same type

To set the color of all the map tiles of the same type, use:

myMap.setColorOfType(yourTileType, yourColor);
4) Setting the color of all the map tiles

To set the color of the entire map, use:

myMap.setMapColor(yourColor);
5) Setting the opacity of a single tile

To set the opacity of a single tile, use:

myMap.setTileOpacity(your3DCoordinates, opacityValue);

Note that you can do this operation directely by coloring the tile, but it is faster to do that.

Accessors: 1) Getting the color of a tile

To get the color of a single tile of the map, call:

myMap.getTileColor(yourTileCoordinates);
Accessors: 2) Getting the color of a tile type

To get the color of a tile type (if set), call:

myMap.getColorOfType(tileType);
Accessors: 3) Getting the color of the map

This function may be used only when Map::setMapOpacity() has been called. Otherwise, the return of this function will not be true for all the tiles. To get the color of all the tiles of the map, call:

myMap.getMapColor();

Well done, you now handles FisoEngine coloring feature !