FastEngine 0.9.4
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::TileLayer Class Reference

A tile layer contain a matrix of global tile id and a list of TileSet. More...

#include <C_tilelayer.hpp>

Inheritance diagram for fge::TileLayer:
fge::BaseLayer fge::Transformable fge::Drawable

Classes

class  Tile
 A tile that contain drawing information and its global id. More...

Public Types

enum class  Types { TILE_LAYER , OBJECT_GROUP }

Public Member Functions

void draw (fge::RenderTarget &target, fge::RenderStates const &states) const override
Types getType () const override
void clear () override
fge::Matrix< Tile > const & getTiles () const
 Get the matrix of tiles.
void setGid (fge::Vector2size position, std::span< std::shared_ptr< TileSet > > tileSets, GlobalTileId gid)
 Shortcut to set a global tile id and a new tileset.
GlobalTileId getGid (fge::Vector2size position) const
std::optional< fge::Vector2size > getGridPosition (fge::Vector2f position) const
void setGid (fge::Vector2size position, GlobalTileId gid)
 Shortcut to set a global tile id.
void setGridSize (fge::Vector2size size)
 Set the tiles matrix size.
void refreshTextures (std::span< std::shared_ptr< TileSet > > tileSets)
 Refresh all tiles with a list of tilesets.
fge::RectFloat getGlobalBounds () const
fge::RectFloat getLocalBounds () const
void save (nlohmann::json &jsonObject) override
void load (nlohmann::json const &jsonObject, std::filesystem::path const &filePath) override
void setId (GlobalTileId id)
 Set the id of the layer (mostly for "Tiled" map editor compatibility)
GlobalTileId getId () const
 Get the id of the layer.
void setName (std::string_view name)
 Set the name of the layer.
std::string const & getName () const
 Get the name of the layer.
template<class T>
constexpr T const * as () const
template<class T>
constexpr T * as ()
void setPosition (Vector2f const &position)
Vector2f const & getPosition () const
void move (Vector2f const &offset)
void setRotation (float angle)
float getRotation () const
void rotate (float angle)
void setScale (Vector2f const &factors)
void setScale (float factor)
Vector2f const & getScale () const
void scale (Vector2f const &factor)
void scale (float factor)
void setOrigin (Vector2f const &origin)
Vector2f const & getOrigin () const
glm::mat4 const & getTransform () const
glm::mat4 const & getInverseTransform () const

Static Public Member Functions

static std::shared_ptr< TileSetretrieveAssociatedTileSet (std::span< std::shared_ptr< TileSet > > tileSets, GlobalTileId gid)
static std::shared_ptr< BaseLayerloadLayer (nlohmann::json const &jsonObject, std::filesystem::path const &filePath)

Detailed Description

A tile layer contain a matrix of global tile id and a list of TileSet.

This class is compatible with the "Tiled" map editor.

Member Function Documentation

◆ clear()

void fge::TileLayer::clear ( )
overridevirtual

Reimplemented from fge::BaseLayer.

◆ draw()

void fge::TileLayer::draw ( fge::RenderTarget & target,
fge::RenderStates const & states ) const
overridevirtual

Implements fge::Drawable.

◆ getId()

GlobalTileId fge::BaseLayer::getId ( ) const
nodiscardinherited

Get the id of the layer.

Returns
The id of the layer

◆ getName()

std::string const & fge::BaseLayer::getName ( ) const
nodiscardinherited

Get the name of the layer.

Returns
The name of the layer

◆ getTiles()

fge::Matrix< Tile > const & fge::TileLayer::getTiles ( ) const
nodiscard

Get the matrix of tiles.

Returns
The matrix of tiles

◆ getType()

Types fge::TileLayer::getType ( ) const
nodiscardoverridevirtual

Implements fge::BaseLayer.

◆ load()

void fge::TileLayer::load ( nlohmann::json const & jsonObject,
std::filesystem::path const & filePath )
overridevirtual

Reimplemented from fge::BaseLayer.

◆ refreshTextures()

void fge::TileLayer::refreshTextures ( std::span< std::shared_ptr< TileSet > > tileSets)

Refresh all tiles with a list of tilesets.

Parameters
tileSetsThe list of tilesets

◆ save()

void fge::TileLayer::save ( nlohmann::json & jsonObject)
overridevirtual

Reimplemented from fge::BaseLayer.

◆ setGid() [1/2]

void fge::TileLayer::setGid ( fge::Vector2size position,
GlobalTileId gid )

Shortcut to set a global tile id.

Parameters
positionThe position of the tile
gidThe global tile id

◆ setGid() [2/2]

void fge::TileLayer::setGid ( fge::Vector2size position,
std::span< std::shared_ptr< TileSet > > tileSets,
GlobalTileId gid )

Shortcut to set a global tile id and a new tileset.

Parameters
positionThe position of the tile
tileSetsThe list of tilesets
gidThe global tile id

◆ setGridSize()

void fge::TileLayer::setGridSize ( fge::Vector2size size)

Set the tiles matrix size.

Parameters
sizeThe size of the matrix

◆ setId()

void fge::BaseLayer::setId ( GlobalTileId id)
inherited

Set the id of the layer (mostly for "Tiled" map editor compatibility)

Parameters
idThe id of the layer

◆ setName()

void fge::BaseLayer::setName ( std::string_view name)
inherited

Set the name of the layer.

Parameters
nameThe name of the layer

The documentation for this class was generated from the following file: