30#include <tmxlite/Config.hpp>
31#include <tmxlite/Property.hpp>
32#include <tmxlite/Types.hpp>
58 using Ptr = std::unique_ptr<Layer>;
60 Layer() : m_opacity(1.f), m_visible(
true) {};
61 virtual ~Layer() =
default;
88 const std::string&
getClass()
const {
return m_class; }
100 template <
typename T>
101 const T& getLayerAs()
const;
106 virtual void parse(
const pugi::xml_node&,
Map* =
nullptr) = 0;
111 const std::string&
getName()
const {
return m_name; }
153 void setName(
const std::string& name) { m_name = name; }
154 void setClass(
const std::string& cls) { m_class = cls; }
155 void setOpacity(
float opacity) { m_opacity = opacity; }
156 void setVisible(
bool visible) { m_visible = visible; }
157 void setOffset(std::int32_t x, std::int32_t y) { m_offset = Vector2i(x, y); }
158 void setParallaxFactor(
float x,
float y) { m_parallaxFactor.x = x; m_parallaxFactor.y = y; }
159 void setTintColour(Colour c) { m_tintColour = c; }
160 void setSize(std::uint32_t width, std::uint32_t height) { m_size = Vector2u(width, height); }
161 void addProperty(
const pugi::xml_node& node) { m_properties.emplace_back(); m_properties.back().parse(node); }
169 Vector2f m_parallaxFactor;
170 Colour m_tintColour = { 255,255,255,255 };
173 std::vector<Property> m_properties;
Represents a layer of a tmx format tile map. This is an abstract base class from which all layer type...
Definition Layer.hpp:56
T & getLayerAs()
Use this to get a reference to the concrete layer type which this layer points to....
const Vector2u & getSize() const
Returns the size of the layer, in pixels. This will be the same as the map size for fixed size maps.
Definition Layer.hpp:144
float getOpacity() const
Returns the opacity value for the layer.
Definition Layer.hpp:116
Type
Layer type as returned by getType() Tile: this layer is a TileLayer type Object: This layer is an Obj...
Definition Layer.hpp:71
Colour getTintColour() const
Returns the tint colour of the layer. Defaults to 0xFFFFFFFF - pure white.
Definition Layer.hpp:138
const std::vector< Property > & getProperties() const
Returns the list of properties of this layer.
Definition Layer.hpp:149
virtual void parse(const pugi::xml_node &, Map *=nullptr)=0
Attempts to parse the specific node layer type.
bool getVisible() const
Returns whether this layer is visible or not.
Definition Layer.hpp:121
virtual Type getType() const =0
Returns a Type value representing the concrete type. Use this when deciding which conrete layer type ...
const Vector2f & getParallaxFactor() const
Returns the parallax factor.
Definition Layer.hpp:132
const std::string & getName() const
Returns the name of the layer.
Definition Layer.hpp:111
const Vector2i & getOffset() const
Returns the offset from the top left corner of the layer, in pixels.
Definition Layer.hpp:127
const std::string & getClass() const
Returns the class of the Layer, as defined in the editor Tiled 1.9+.
Definition Layer.hpp:88
Parser for TMX format tile maps. This class can be used to parse the XML format tile maps created wit...
Definition Map.hpp:94
Objects are stored in ObjectGroup layers. Objects may be rectangular, elliptical, polygonal or a poly...
Definition Object.hpp:84
Contains the red, green, blue and alpha values of a colour in the range 0 - 255.
Definition Types.hpp:111