tmxparser  2.1.0
 All Classes Functions Variables Pages
TmxObjectGroup.h
1 //-----------------------------------------------------------------------------
2 // TmxObjectGroup.h
3 //
4 // Copyright (c) 2010-2014, Tamir Atias
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
19 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Author: Tamir Atias
27 //-----------------------------------------------------------------------------
28 #pragma once
29 
30 #include <string>
31 #include <vector>
32 
33 #include "TmxLayer.h"
34 #include "TmxPropertySet.h"
35 
36 namespace tinyxml2 {
37  class XMLNode;
38 }
39 
40 namespace Tmx
41 {
42  class Object;
43 
44  //-------------------------------------------------------------------------
47  //-------------------------------------------------------------------------
48  class ObjectGroup : public Tmx::Layer
49  {
50  public:
52  ObjectGroup(const Tmx::Map *_map);
53 
55  ObjectGroup(const Tmx::Tile *_tile);
56 
57  ~ObjectGroup();
58 
60  void Parse(const tinyxml2::XMLNode *objectGroupNode);
61 
63  const Tmx::Object *GetObject(int index) const { return objects.at(index); }
64 
66  int GetNumObjects() const { return objects.size(); }
67 
69  Tmx::Color GetColor() const { return color; }
70 
72  const std::vector< Tmx::Object* > &GetObjects() const { return objects; }
73 
75  const Tmx::PropertySet &GetProperties() const { return properties; }
76 
77  private:
78  Tmx::Color color;
79 
80  std::vector< Tmx::Object* > objects;
81  Tmx::PropertySet properties;
82  };
83 }
Base class for other layer types.
Definition: TmxLayer.h:54
const Tmx::Object * GetObject(int index) const
Get a single object.
Definition: TmxObjectGroup.h:63
const Tmx::PropertySet & GetProperties() const
Get the property set.
Definition: TmxObjectGroup.h:75
A class used for holding a list of objects.
Definition: TmxObjectGroup.h:48
This class is the root class of the parser.
Definition: TmxMap.h:115
This class contains a map of properties.
Definition: TmxPropertySet.h:47
Class used for representing a single object from the objectgroup.
Definition: TmxObject.h:48
const std::vector< Tmx::Object * > & GetObjects() const
Get the whole list of objects.
Definition: TmxObjectGroup.h:72
Tmx::Color GetColor() const
Get the color used to display the objects in this group.
Definition: TmxObjectGroup.h:69
ObjectGroup(const Tmx::Map *_map)
Construct a new ObjectGroup.
Definition: TmxObjectGroup.cpp:36
A class used for storing information about a color.
Definition: TmxColor.h:38
Class to contain information about every tile in the tileset/tiles element.
Definition: TmxTile.h:51
void Parse(const tinyxml2::XMLNode *objectGroupNode)
Parse an objectgroup node.
Definition: TmxObjectGroup.cpp:57
int GetNumObjects() const
Get the number of objects in the list.
Definition: TmxObjectGroup.h:66