![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
A tileset. More...
#include <gf/Tileset.h>
Public Member Functions | |
Tileset () | |
void | setTexture (Texture &texture) |
Change the source texture of the tileset. More... | |
const Texture & | getTexture () const |
Get the source texture of the tileset. More... | |
void | setSmooth (bool smooth=true) |
Enable or disable the smooth filter on the texture. More... | |
bool | hasTexture () const |
Check if a texture is set. More... | |
void | unsetTexture () |
Unset the source texture of the tile layer. More... | |
void | setTileSize (Vector2i tileSize) |
Set the tile size in the tileset. More... | |
Vector2i | getTileSize () const |
Get the tile size in the tileset. More... | |
void | setMargin (int margin) |
Set the margin of the tileset. More... | |
void | setMargin (Vector2i margin) |
Set the margin of the tileset. More... | |
Vector2i | getMargin () const |
Get the margin of the tileset. More... | |
void | setSpacing (int spacing) |
Set the spacing of the tileset. More... | |
void | setSpacing (Vector2i spacing) |
Set the spacing of the tileset. More... | |
Vector2i | getSpacing () const |
Get the spacing of the tileset. More... | |
void | setOffset (Vector2i offset) |
Set the offset of the tileset. More... | |
Vector2i | getOffset () const |
Get the offset of the tileset. More... | |
Vector2i | getSize () const |
Get the size of the tileset. More... | |
RectF | computeTextureCoords (int tile) const |
Get the texture coordinates for a tile. More... | |
RectF | computeTextureCoords (Vector2i coords) const |
Get the texture coordinates for a tile. More... | |
A tileset.
A tileset is a texture that contains all the tiles, ordered in a grid. The tileset has several parameters that are inspired by the parameters in Tiled:
setTileSize()
, getTileSize()
)setMargin()
, getMargin()
), default: \( (0,0) \)setSpacing()
, getSpacing()
), default: \( (0,0) \)gf::Tileset::Tileset | ( | ) |
RectF gf::Tileset::computeTextureCoords | ( | int | tile | ) | const |
Get the texture coordinates for a tile.
tile | The tile number |
Get the texture coordinates for a tile.
coords | The tile coordinates |
|
inline |
|
inline |
|
inline |
Get the size of the tileset.
|
inline |
|
inline |
Get the source texture of the tileset.
The returned reference is const, which means that you can't modify the texture when you retrieve it with this function.
|
inline |
|
inline |
Check if a texture is set.
|
inline |
void gf::Tileset::setMargin | ( | Vector2i | margin | ) |
void gf::Tileset::setOffset | ( | Vector2i | offset | ) |
|
inline |
Enable or disable the smooth filter on the texture.
smooth | True to enable smoothing, false to disable it |
|
inline |
void gf::Tileset::setSpacing | ( | Vector2i | spacing | ) |
void gf::Tileset::setTexture | ( | Texture & | texture | ) |
Change the source texture of the tileset.
The texture must exist as long as the tile layer uses it. Indeed, the tile layer doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the tile layer tries to use it, the behavior is undefined.
texture | New texture |
void gf::Tileset::setTileSize | ( | Vector2i | tileSize | ) |
Set the tile size in the tileset.
tileSize | The new tile size, in pixels |
void gf::Tileset::unsetTexture | ( | ) |
Unset the source texture of the tile layer.
After a call to this function, the tile layer has no source texture.