-
Notifications
You must be signed in to change notification settings - Fork 31
Layer
A Layer is a part of a Level and can contain Tiles or Entities.
const ldtk::Level* ldtk::Layer::levelPointer to the Level object that contains the Layer.
const std::string ldtk::Layer::iidUnique instance ID of the Layer.
getTypegetNameisVisiblegetCellSizegetGridSizegetOffsetgetOpacityhasTilesetgetTilesetallTilesgetTilegetTilesByEnumTaggetIntGridValgetIntGridValPositionshasEntityallEntitiesgetEntitiesByNamegetEntitiesByTag
ldtk::Layer::getType() const -> const ldtk::LayerType&Returns the type of the Layer (IntGrid, Entities, Tiles or AutoLayer).
ldtk::Layer::getName() const -> const std::string&Returns the name of the Layer.
ldtk::Layer::isVisible() const -> boolReturns true if the Layer is visible in the editor, returns false otherwise.
ldtk::Layer::getCellSize() const -> intReturns the size of grid cells (cell_size x cell_size).
ldtk::Layer::getGridSize() const -> const ldtk::IntPoint&Returns the size of the grid in cells (the width and height of the level in cells number, not in pixel).
ldtk::Layer::getOffset() const -> const ldtk::IntPoint&Returns Layer total offset in pixels.
ldtk::Layer::getOpacity() const -> floatReturns Layer opacity.
ldtk::Layer::hasTileset() const -> boolReturns true if the Layer has a Tileset, returns false otherwise.
ldtk::Layer::getTileset() const -> const ldtk::Tileset&Returns the Tileset used by the Layer.
Throws an invalid_argument exception if Layer does not have a Tileset.
ldtk::Layer::allTiles() const -> const std::vector<ldtk::Tile>&Returns a vector containing all the Tiles in the Layer, ordered correctly.
ldtk::Layer::getTile(int x, int y) const -> const Tile&Returns the Tile located at (x, y) grid position.
Returns ldtk::Tile::None if there is no tile at the position.
ldtk::Layer::getTilesByEnumTag(const EnumValue&) const -> const std::vector<std::reference_wrapper<Tile>>&Returns a vector containing reference wrappers of Tiles tagged with the given EnumValue.
Because the returned vector contains reference wrappers, using auto won't work as expected,
you have to explicitly specify the type when iterating :
const auto& chest_enumval = world.getEnum("Items")["Chest"];
for (const ldtk::Tile& chest_tiles : layer.getTilesByEnumTag(chest_enumval)) {
// ...
}ldtk::Layer::getIntGridVal(int x, int y) const -> const IntGridValue&Returns the IntGridValue value located at (x, y) grid position.
Returns ldtk::IntGridValue::None if there is no IntGridValue at the position.
ldtk::Layer::getIntGridValPositions(int value) const -> const std::vector<IntPoint>&Returns a vector containing the grid positions of all tiles of the given IntGridValue value.
ldtk::Layer::getIntGridValPositions(const std::string& name) const -> const std::vector<IntPoint>&Returns a vector containing the grid positions of all tiles of the given IntGridValue name.
ldtk::Layer::hasEntity(const std::string& name) const -> boolReturns true if Layer has an Entity with the provided name, returns false otherwise.
ldtk::Layer::allEntities() const -> const std::vector<Entity>&Returns a vector containing all Entities of the Layer.
ldtk::Layer::getEntitiesByName(const std::string& name) const -> const std::vector<std::reference_wrapper<Entity>>&Returns a vector containing reference wrappers of Entities named as the provided name.
Because the returned vector contains reference wrappers, using auto won't work as expected,
you have to explicitly specify the type when iterating :
for (const ldtk::Entity& slime : layer.getEntitiesByName("Slime")) {
// ...
}ldtk::Layer::getEntitiesByTag(const std::string& tag) const -> const std::vector<std::reference_wrapper<Entity>>&Returns a vector containing reference wrappers of Entities tagged with the provided tag name.
Because the returned vector contains reference wrappers, using auto won't work as expected,
you have to explicitly specify the type when iterating :
for (const ldtk::Entity& actionable : layer.getEntitiesByTag("actionable")) {
// ...
}