Uranus  1.0.1.0
Uranus is a GameEngine written in C++
Loading...
Searching...
No Matches
tson::Tile Class Reference
Collaboration diagram for tson::Tile:
[legend]

Public Member Functions

 Tile (IJson &json, tson::Tileset *tileset, tson::Map *map)
 
 Tile (uint32_t id, tson::Map *map)
 
 Tile (uint32_t id, tson::Tileset *tileset, tson::Map *map)
 
void addTilesetAndPerformCalculations (tson::Tileset *tileset)
 
template<typename T >
get (const std::string &name)
 
tson::AnimationgetAnimation ()
 
tson::TiledClassgetClass ()
 
const std::string & getClassType () const
 
const tson::RectgetDrawingRect () const
 
TileFlipFlags getFlipFlags () const
 
uint32_t getGid () const
 
uint32_t getId () const
 
const fs::path & getImage () const
 
const Vector2igetImageSize () const
 
tson::MapgetMap () const
 
LayergetObjectgroup ()
 
const tson::Vector2f getPosition (const std::tuple< int, int > &tileDataPos)
 
const tson::Vector2i getPositionInTileUnits (const std::tuple< int, int > &tileDataPos)
 
tson::PropertygetProp (const std::string &name)
 
PropertyCollectiongetProperties ()
 
const RectgetSubRectangle () const
 
const std::vector< int > & getTerrain () const
 
tson::TilesetgetTileset () const
 
const tson::Vector2i getTileSize () const
 
const std::string & getType () const
 
bool hasFlipFlags (TileFlipFlags flags)
 
bool parse (IJson &json, tson::Tileset *tileset, tson::Map *map)
 
bool parseId (IJson &json)
 
void setProperties (const tson::PropertyCollection &properties)
 

Private Member Functions

void manageFlipFlagsByIdThenRemoveFlags (uint32_t &id)
 
void performDataCalculations ()
 

Private Attributes

tson::Animation m_animation {}
 
std::shared_ptr< tson::TiledClassm_class {}
 
tson::Rect m_drawingRect
 
tson::TileFlipFlags m_flipFlags = TileFlipFlags::None
 
uint32_t m_gid {}
 
uint32_t m_id {}
 
fs::path m_image
 
tson::Vector2i m_imageSize
 
tson::Mapm_map
 
tson::Layer m_objectgroup
 
tson::PropertyCollection m_properties
 
tson::Rect m_subRect
 
std::vector< int > m_terrain
 
tson::Tilesetm_tileset
 
std::string m_type
 

Friends

class Layer
 

Constructor & Destructor Documentation

◆ Tile() [1/2]

tson::Tile::Tile ( uint32_t  id,
tson::Tileset tileset,
tson::Map map 
)
inline

Used in cases where you have a tile without any property

Parameters
id

◆ Tile() [2/2]

tson::Tile::Tile ( uint32_t  id,
tson::Map map 
)
inline

Used in cases where you have a FLIP FLAGGED tile

Parameters
id

Member Function Documentation

◆ addTilesetAndPerformCalculations()

void tson::Tile::addTilesetAndPerformCalculations ( tson::Tileset tileset)
inline

For flip flagged tiles, tilesets must be resolved later.

Parameters
tileset

◆ get()

template<typename T >
T tson::Tile::get ( const std::string &  name)
inline

A shortcut for getting a property. Alternative to getProperties().getValue<T>("<name>")

Template Parameters
TThe template value
Parameters
nameName of the property
Returns
The actual value, if it exists. Otherwise: The default value of the type.

◆ getAnimation()

tson::Animation & tson::Tile::getAnimation ( )
inline

Declared in tileson_forward.hpp

'animation': Array of Frames

Returns

◆ getClass()

tson::TiledClass * tson::Tile::getClass ( )
inline

Gets the class information for the 'type'/'class' This may only give a valid result if the map is loaded through a tson::Project

Returns
a tson::TiledClass object if related map was loaded through tson::Project

◆ getClassType()

const std::string & tson::Tile::getClassType ( ) const
inline

'class': String assigned to class field in editor (optional) This was renamed from 'type' to 'class' in Tiled v1.9

Returns

◆ getDrawingRect()

const tson::Rect & tson::Tile::getDrawingRect ( ) const
inline

Get the information needed to draw the Tile based on its current tileset

Returns
a tson::Rect containing the information needed to draw the tile.

◆ getFlipFlags()

tson::TileFlipFlags tson::Tile::getFlipFlags ( ) const
inline

Declared in tileson_forward.hpp

◆ getId()

uint32_t tson::Tile::getId ( ) const
inline

'id': Local ID of the tile

Returns

◆ getImage()

const fs::path & tson::Tile::getImage ( ) const
inline

'image': Image representing this tile (optional)

Returns

◆ getImageSize()

const tson::Vector2i & tson::Tile::getImageSize ( ) const
inline

x = 'imagewidth' and y = 'imageheight': in pixels

Returns

◆ getMap()

tson::Map * tson::Tile::getMap ( ) const
inline

Used for getting the tson::Map who is the parent of this Tile.

Returns
a pointer to the tson::Map where this tile is contained.

◆ getObjectgroup()

tson::Layer & tson::Tile::getObjectgroup ( )
inline

'objectgroup': Layer with type objectgroup (optional)

Returns

◆ getPosition()

const tson::Vector2f tson::Tile::getPosition ( const std::tuple< int, int > &  tileDataPos)
inline

Get the position of the tile in pixels based on the tile data position from the current layer.

Returns
The position of the tile in Pixels

◆ getPositionInTileUnits()

const tson::Vector2i tson::Tile::getPositionInTileUnits ( const std::tuple< int, int > &  tileDataPos)
inline

Helper function.

Get the position of the tile in tile units. The size of each unit is determined by the tile size property of the map. Example: If the tile size is 16x16 in the map, a tile unit of [2, 4] would be [32, 64] in pixels. If you want the position in pixels: use getPosition() instead.

Returns
Position of tile in tile units.

◆ getProp()

tson::Property * tson::Tile::getProp ( const std::string &  name)
inline

Shortcut for getting a property object. Alternative to getProperties().getProperty("<name>");

Parameters
nameName of the property
Returns

◆ getProperties()

tson::PropertyCollection & tson::Tile::getProperties ( )
inline

'properties': A list of properties (name, value, type).

Returns

◆ getSubRectangle()

const tson::Rect & tson::Tile::getSubRectangle ( ) const
inline

Tiled 1.9: Contains the newly added sub-rectangle variables: 'x', 'y', 'width' and 'height'

Returns
A tson::Rect with the 'x', 'y', 'width' and 'height' values

◆ getTerrain()

const std::vector< int > & tson::Tile::getTerrain ( ) const
inline

'terrain': Index of terrain for each corner of tile

Returns

◆ getTileset()

tson::Tileset * tson::Tile::getTileset ( ) const
inline

Used for getting the tson::Tileset who is the parent of this Tile.

Returns
a pointer to the tson::Tileset where this tile is contained.

◆ getTileSize()

const tson::Vector2i tson::Tile::getTileSize ( ) const
inline

Really just a shortcut to retrieve the tile size from the map.

Returns
TileSize based on the map property for tile size.

◆ getType()

const std::string & tson::Tile::getType ( ) const
inline

'type': The type of the tile (optional) This was renamed to 'class' in Tiled v1.9

Returns

◆ hasFlipFlags()

bool tson::Tile::hasFlipFlags ( tson::TileFlipFlags  flags)
inline
Parameters
flagsWhich flags to check for. Several flags can be checked at once using the bitwise or operator. Example: hasFlipFlags(TileFlipFlags::Vertically | TileFlipFlags::Horizontally)
Returns
true if the flag(s) specified are set

◆ manageFlipFlagsByIdThenRemoveFlags()

void tson::Tile::manageFlipFlagsByIdThenRemoveFlags ( uint32_t &  id)
inlineprivate

Declared in tileson_forward.hpp - Calculate all the values used in the tile class.

◆ parse()

bool tson::Tile::parse ( IJson json,
tson::Tileset tileset,
tson::Map map 
)
inline

Parses a tile from a Tiled json. id on tile is store as id + 1 to match the references in data containers.

Parameters
json
Returns

◆ performDataCalculations()

void tson::Tile::performDataCalculations ( )
inlineprivate

Resolved using bit 32, 31 and 30 from gid

Uses tson::Tileset and tson::Map data to calculate related values for tson::Tile. Added in v1.2.0

Field Documentation

◆ m_drawingRect

tson::Rect tson::Tile::m_drawingRect
private

A pointer to the map where this tile is contained

◆ m_flipFlags

tson::TileFlipFlags tson::Tile::m_flipFlags = TileFlipFlags::None
private

Tiled 1.9: Contains the newly added sub-rectangle variables: 'x', 'y', 'width' and 'height'

◆ m_gid

uint32_t tson::Tile::m_gid {}
private

'type': The type of the tile (optional)

◆ m_id

uint32_t tson::Tile::m_id {}
private

'animation': Array of Frames

◆ m_image

fs::path tson::Tile::m_image
private

'id': Local ID of the tile

◆ m_imageSize

tson::Vector2i tson::Tile::m_imageSize
private

'image': Image representing this tile (optional)

◆ m_map

tson::Map* tson::Tile::m_map
private

A pointer to the tileset where this Tile comes from

◆ m_objectgroup

tson::Layer tson::Tile::m_objectgroup
private

x = 'imagewidth' and y = 'imageheight': in pixels

◆ m_properties

tson::PropertyCollection tson::Tile::m_properties
private

'objectgroup': Layer with type objectgroup (optional)

◆ m_subRect

tson::Rect tson::Tile::m_subRect
private

A rect that shows which part of the tileset that is used for this tile

◆ m_terrain

std::vector<int> tson::Tile::m_terrain
private

'properties': A list of properties (name, value, type).

◆ m_tileset

tson::Tileset* tson::Tile::m_tileset
private

id without flip flags

◆ m_type

std::string tson::Tile::m_type
private

'terrain': Index of terrain for each corner of tile


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