|
| Layer (IJson &json, tson::Map *map) |
|
void | assignTileMap (std::map< uint32_t, tson::Tile * > *tileMap) |
|
void | createTileData (const Vector2i &mapSize, bool isInfiniteMap) |
|
tson::Object * | firstObj (const std::string &name) |
|
template<typename T > |
T | get (const std::string &name) |
|
const std::string & | getBase64Data () const |
|
std::vector< tson::Chunk > & | getChunks () |
|
tson::TiledClass * | getClass () |
|
const std::string & | getClassType () const |
|
const std::string & | getCompression () const |
|
const std::vector< uint32_t > & | getData () const |
|
const std::string & | getDrawOrder () const |
|
const std::string & | getEncoding () const |
|
int | getId () const |
|
const std::string & | getImage () const |
|
std::vector< tson::Layer > & | getLayers () |
|
tson::Map * | getMap () const |
|
const std::string & | getName () const |
|
tson::Object * | getObj (int id) |
|
std::vector< tson::Object > & | getObjects () |
|
std::vector< tson::Object > | getObjectsByName (const std::string &name) |
|
std::vector< tson::Object > | getObjectsByType (tson::ObjectType type) |
|
const Vector2f & | getOffset () const |
|
float | getOpacity () const |
|
const Vector2f & | getParallax () const |
|
tson::Property * | getProp (const std::string &name) |
|
PropertyCollection & | getProperties () |
|
const Vector2i & | getSize () const |
|
const std::map< std::tuple< int, int >, tson::Tile * > & | getTileData () const |
|
tson::Tile * | getTileData (int x, int y) |
|
tson::TileObject * | getTileObject (int x, int y) |
|
std::map< std::tuple< int, int >, tson::TileObject > & | getTileObjects () |
|
const Colori & | getTintColor () const |
|
const Colori & | getTransparentColor () const |
|
LayerType | getType () const |
|
const std::string & | getTypeStr () const |
|
const std::set< uint32_t > & | getUniqueFlaggedTiles () const |
|
int | getX () const |
|
int | getY () const |
|
bool | hasRepeatX () const |
|
bool | hasRepeatY () const |
|
bool | isVisible () const |
|
bool | parse (IJson &json, tson::Map *map) |
|
void | resolveFlaggedTiles () |
|
◆ Layer()
Parses a Tiled layer from json
- Parameters
-
◆ assignTileMap()
void tson::Layer::assignTileMap |
( |
std::map< uint32_t, tson::Tile * > * |
tileMap | ) |
|
|
inline |
Assigns a tilemap of pointers to existing tiles.
- Parameters
-
tileMap | The tilemap. key: tile id, value: pointer to Tile. |
◆ createTileData()
void tson::Layer::createTileData |
( |
const Vector2i & |
mapSize, |
|
|
bool |
isInfiniteMap |
|
) |
| |
|
inline |
This is only supported for non-infinite maps!
- Parameters
-
mapSize | The size of the map |
isInfiniteMap | Whether or not the current map is infinte. |
◆ decompressData()
void tson::Layer::decompressData |
( |
| ) |
|
|
inlineprivate |
'tintcolor': Hex-formatted color (#RRGGBB or #AARRGGBB) that is multiplied with any graphics drawn by this layer or any child layers (optional).
Decompresses data if there are matching decompressors
◆ firstObj()
tson::Object * tson::Layer::firstObj |
( |
const std::string & |
name | ) |
|
|
inline |
Returns the first object with the given name
- Parameters
-
name | Name of the object to find. |
- Returns
- A pointer to the object if found. nullptr otherwise.
◆ get()
template<typename T >
T tson::Layer::get |
( |
const std::string & |
name | ) |
|
|
inline |
A shortcut for getting a property. Alternative to getProperties().getValue<T>("<name>")
- Template Parameters
-
- Parameters
-
- Returns
- The actual value, if it exists. Otherwise: The default value of the type.
◆ getBase64Data()
const std::string & tson::Layer::getBase64Data |
( |
| ) |
const |
|
inline |
'data' (when string): Array of unsigned int (GIDs) or base64-encoded data. tilelayer only.
- Returns
◆ getChunks()
std::vector< tson::Chunk > & tson::Layer::getChunks |
( |
| ) |
|
|
inline |
'chunks': Array of chunks (optional). tilelayer only.
- Returns
◆ getCompression()
const std::string & tson::Layer::getCompression |
( |
| ) |
const |
|
inline |
'compression': zlib, gzip or empty (default). tilelayer only.
- Returns
◆ getData()
const std::vector< uint32_t > & tson::Layer::getData |
( |
| ) |
const |
|
inline |
'data' (when uint array): Array of unsigned int (GIDs) or base64-encoded data. tilelayer only.
- Returns
◆ getDrawOrder()
const std::string & tson::Layer::getDrawOrder |
( |
| ) |
const |
|
inline |
'draworder': topdown (default) or index. objectgroup only.
- Returns
◆ getEncoding()
const std::string & tson::Layer::getEncoding |
( |
| ) |
const |
|
inline |
'encoding': csv (default) or base64. tilelayer only.
- Returns
◆ getId()
int tson::Layer::getId |
( |
| ) |
const |
|
inline |
'id': Incremental id - unique across all layers
- Returns
◆ getImage()
const std::string & tson::Layer::getImage |
( |
| ) |
const |
|
inline |
'image': Image used by this layer. imagelayer only.
- Returns
◆ getLayers()
std::vector< tson::Layer > & tson::Layer::getLayers |
( |
| ) |
|
|
inline |
'layers': Array of layers. group on
- Returns
◆ getMap()
Used for getting the tson::Map who is the parent of this Layer.
- Returns
- a pointer to the tson::Map where this layer is contained.
◆ getName()
const std::string & tson::Layer::getName |
( |
| ) |
const |
|
inline |
'name': Name assigned to this layer
- Returns
◆ getObj()
Get an object by ID
- Parameters
-
id | Unique ID of the object |
- Returns
- A pointer to the object if found. nullptr otherwise.
◆ getObjects()
'objects': Array of objects. objectgroup only.
- Returns
◆ getObjectsByName()
std::vector< tson::Object > tson::Layer::getObjectsByName |
( |
const std::string & |
name | ) |
|
|
inline |
Copies all objects with a name that equals the parameter
- Parameters
-
name | Name of the objects to return |
- Returns
- All objects with a matching name
◆ getObjectsByType()
std::vector< tson::Object > tson::Layer::getObjectsByType |
( |
tson::ObjectType |
type | ) |
|
|
inline |
Copies all objects with a type that equals the parameter
- Parameters
-
type | LayerType of the objects to return |
- Returns
- All objects with a matching type
◆ getOffset()
'offsetx' and 'offsety': Horizontal and Vertical layer offset in pixels (default: {0, 0})
- Returns
◆ getOpacity()
float tson::Layer::getOpacity |
( |
| ) |
const |
|
inline |
'opacity': Value between 0 and 1
- Returns
◆ getParallax()
New in Tiled v1.5 Gets the parallax factor for current layer. Defaults to 1.
- Returns
- A vector with the x and y values of the parallax factor.
◆ getProp()
Shortcut for getting a property object. Alternative to getProperties().getProperty("<name>");
- Parameters
-
- Returns
◆ getProperties()
'properties': A list of properties (name, value, type).
- Returns
◆ getSize()
x = 'width': (Column count. Same as map width for fixed-size maps.) y = 'height': Row count. Same as map height for fixed-size maps.
- Returns
- width and height as a single size
◆ getTileData() [1/2]
const std::map< std::tuple< int, int >, tson::Tile * > & tson::Layer::getTileData |
( |
| ) |
const |
|
inline |
Get tile data as some kind of map with x and y position with pointers to existing tiles. Map only contains tiles that are not empty. x and y position is in tile units.
Example of getting tile from the returned map:
Tile *tile = tileData[{0, 4}];
- Returns
- A map that represents the data returned from getData() in a 2D map with Tile pointers.
◆ getTileData() [2/2]
tson::Tile * tson::Layer::getTileData |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
inline |
A safe way to get tile data Get tile data as some kind of map with x and y position with pointers to existing tiles. Map only contains tiles that are not empty. x and y position is in tile units.
Example of getting tile: Tile *tile = layer->getTileData(0, 4)
- Parameters
-
x | X position in tile units |
y | Y position in tile units |
- Returns
- pointer to tile, if it exists. nullptr otherwise.
◆ getTintColor()
'tintcolor': Hex-formatted color (#RRGGBB or #AARRGGBB) that is multiplied with any graphics drawn by this layer or any child layers (optional).
- Returns
- tintcolor
◆ getTransparentColor()
const tson::Colori & tson::Layer::getTransparentColor |
( |
| ) |
const |
|
inline |
'transparentcolor': Color created from a hex color (#RRGGBB) (optional, imagelayer only)
- Returns
- color as color object with rgba channel.
◆ getType()
tson::LayerType tson::Layer::getType |
( |
| ) |
const |
|
inline |
Get layer type
- Returns
- Layer type as enum
◆ getTypeStr()
const std::string & tson::Layer::getTypeStr |
( |
| ) |
const |
|
inline |
Declared in tileson_forward.hpp
'type': tilelayer, objectgroup, imagelayer or group
- Returns
- string with the object type
◆ getX()
int tson::Layer::getX |
( |
| ) |
const |
|
inline |
'x': Horizontal layer offset in tiles. Always 0.
- Returns
- x value (always 0 for layer)
◆ getY()
int tson::Layer::getY |
( |
| ) |
const |
|
inline |
'y': Horizontal layer offset in tiles. Always 0.
- Returns
- y value (always 0 for layer)
◆ hasRepeatX()
bool tson::Layer::hasRepeatX |
( |
| ) |
const |
|
inline |
New in Tiled v1.8 'repeatx': Whether the image drawn by this layer is repeated along the X axis.
- Returns
- true if image layer is repeated along the X axis, false otherwise.
◆ hasRepeatY()
bool tson::Layer::hasRepeatY |
( |
| ) |
const |
|
inline |
New in Tiled v1.8 'repeatx': Whether the image drawn by this layer is repeated along the Y axis.
- Returns
- true if image layer is repeated along the Y axis, false otherwise.
◆ isVisible()
bool tson::Layer::isVisible |
( |
| ) |
const |
|
inline |
'visible': Whether layer is shown or hidden in editor
- Returns
◆ parse()
Parses a Tiled layer from json
- Parameters
-
- Returns
- true if all mandatory fields was found. false otherwise.
◆ queueFlaggedTile()
void tson::Layer::queueFlaggedTile |
( |
size_t |
x, |
|
|
size_t |
y, |
|
|
uint32_t |
id |
|
) |
| |
|
inlineprivate |
Defined in tileson_forward.hpp
◆ setTypeByString()
void tson::Layer::setTypeByString |
( |
| ) |
|
|
inlineprivate |
Set type by string tilelayer, objectgroup, imagelayer or group
◆ m_base64Data
std::string tson::Layer::m_base64Data |
|
private |
'data' (when uint array): Array of unsigned int (GIDs) or base64-encoded data. tilelayer only.
◆ m_class
'class': The class of this map (since 1.9, defaults to “”).
◆ m_compression
std::string tson::Layer::m_compression |
|
private |
'chunks': Array of chunks (optional). tilelayer only.
◆ m_data
std::vector<uint32_t> tson::Layer::m_data |
|
private |
'compression': zlib, gzip or empty (default). tilelayer only.
◆ m_drawOrder
std::string tson::Layer::m_drawOrder |
|
private |
'data' (when string): Array of unsigned int (GIDs) or base64-encoded data. tilelayer only.
◆ m_encoding
std::string tson::Layer::m_encoding |
|
private |
'draworder': topdown (default) or index. objectgroup only.
◆ m_id
'encoding': csv (default) or base64. tilelayer only.
◆ m_image
std::string tson::Layer::m_image |
|
private |
'id': Incremental id - unique across all layers
◆ m_layers
'image': Image used by this layer. imagelayer only.
◆ m_map
◆ m_name
std::string tson::Layer::m_name |
|
private |
'layers': Array of layers. group on
◆ m_objects
'name': Name assigned to this layer
◆ m_offset
'objects': Array of objects. objectgroup only.
◆ m_opacity
float tson::Layer::m_opacity {} |
|
private |
'offsetx' and 'offsety': Horizontal and Vertical layer offset in pixels (default: {0, 0})
◆ m_parallax
'y': Vertical layer offset in tiles. Always 0.
◆ m_properties
'opacity': Value between 0 and 1
◆ m_repeatX
bool tson::Layer::m_repeatX {} |
|
private |
Tiled v1.5: parallax factor for this layer. Defaults to 1. x = 'parallaxx', y = 'parallaxy'
◆ m_repeatY
bool tson::Layer::m_repeatY {} |
|
private |
'repeatx': Whether the image drawn by this layer is repeated along the X axis. (since Tiled 1.8)
◆ m_size
'properties': A list of properties (name, value, type).
◆ m_tileMap
std::map<uint32_t, tson::Tile *>* tson::Layer::m_tileMap |
|
private |
'repeaty': Whether the image drawn by this layer is repeated along the Y axis. (since Tiled 1.8)
◆ m_tileObjects
The map who owns this layer
◆ m_tintColor
Key: Tuple of x and y pos in tile units.
◆ m_transparentColor
x = 'width': (Column count. Same as map width for fixed-size maps.) y = 'height': Row count. Same as map height for fixed-size maps.
◆ m_type
LayerType tson::Layer::m_type {LayerType::Undefined} |
|
private |
'type': tilelayer, objectgroup, imagelayer or group
◆ m_typeStr
std::string tson::Layer::m_typeStr |
|
private |
'transparentcolor': Hex-formatted color (#RRGGBB) (optional, imagelayer only
◆ m_visible
bool tson::Layer::m_visible {} |
|
private |
◆ m_x
'visible': Whether layer is shown or hidden in editor
◆ m_y
'x': Horizontal layer offset in tiles. Always 0.
The documentation for this class was generated from the following file: