tmxlite
lightweight Tiled tmx map parser for C++
ObjectGroup.hpp
1 /*********************************************************************
2 Matt Marchant 2016
3 http://trederia.blogspot.com
4 
5 tmxlite - Zlib license.
6 
7 This software is provided 'as-is', without any express or
8 implied warranty. In no event will the authors be held
9 liable for any damages arising from the use of this software.
10 
11 Permission is granted to anyone to use this software for any purpose,
12 including commercial applications, and to alter it and redistribute
13 it freely, subject to the following restrictions:
14 
15 1. The origin of this software must not be misrepresented;
16 you must not claim that you wrote the original software.
17 If you use this software in a product, an acknowledgment
18 in the product documentation would be appreciated but
19 is not required.
20 
21 2. Altered source versions must be plainly marked as such,
22 and must not be misrepresented as being the original software.
23 
24 3. This notice may not be removed or altered from any
25 source distribution.
26 *********************************************************************/
27 
28 #ifndef TMXLITE_OBJECTGROUP_HPP_
29 #define TMXLITE_OBJECTGROUP_HPP_
30 
31 #include <tmxlite/Config.hpp>
32 #include <tmxlite/Layer.hpp>
33 #include <tmxlite/Object.hpp>
34 
35 #include <vector>
36 
37 namespace tmx
38 {
43  class TMXLITE_EXPORT_API ObjectGroup final : public Layer
44  {
45  public:
46  enum class DrawOrder
47  {
48  Index, //< objects should be drawn in the order in which they appear
49  TopDown //< objects should be drawn sorted by their Y position
50  };
51 
52  ObjectGroup();
53  ~ObjectGroup() = default;
54 
55  Type getType() const override { return Layer::Type::Object; }
56  void parse(const pugi::xml_node&) override;
57 
61  const Colour& getColour() const { return m_colour; }
66  DrawOrder getDrawOrder() const { return m_drawOrder; }
71  const std::vector<Property>& getProperties() const { return m_properties; }
75  const std::vector<Object>& getObjects() const { return m_objects; }
76 
77  private:
78  Colour m_colour;
79  DrawOrder m_drawOrder;
80 
81  std::vector<Property> m_properties;
82  std::vector<Object> m_objects;
83  };
84 }
85 
86 #endif //TMXLITE_OBJECTGROUP_HPP_
const std::vector< Property > & getProperties() const
Returns a reference to the vector of properties for the ObjectGroup.
Definition: ObjectGroup.hpp:71
Definition: Log.hpp:58
Contains the red, green, blue and alpha values of a colour in the range 0 - 255.
Definition: Types.hpp:109
DrawOrder getDrawOrder() const
Returns the DrawOrder for the objects in this group. Defaults to TopDown, where Objects are drawn sor...
Definition: ObjectGroup.hpp:66
Represents a layer of a tmx format tile map. This is an abstract base class from which all layer type...
Definition: Layer.hpp:52
ObjectGroup layers contain a series of Objects which may be made up of shapes or images.
Definition: ObjectGroup.hpp:43
Type getType() const override
Returns a Type value representing the concrete type.
Definition: ObjectGroup.hpp:55
const std::vector< Object > & getObjects() const
Returns a reference to the vector of Objects which belong to the group.
Definition: ObjectGroup.hpp:75
const Colour & getColour() const
Returns the colour associated with this layer.
Definition: ObjectGroup.hpp:61