tmxparser  2.1.0
 All Classes Functions Variables Pages
TmxObject.h
1 //-----------------------------------------------------------------------------
2 // TmxObject.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 
32 #include "TmxPropertySet.h"
33 
34 namespace tinyxml2 {
35  class XMLNode;
36 }
37 
38 namespace Tmx
39 {
40  class Ellipse;
41  class Polygon;
42  class Polyline;
43  class Text;
44 
45  //-------------------------------------------------------------------------
47  //-------------------------------------------------------------------------
48  class Object
49  {
50  public:
51  Object();
52  ~Object();
53 
55  void Parse(const tinyxml2::XMLNode *objectNode);
56 
58  const std::string &GetName() const { return name; }
59 
61  const std::string &GetType() const { return type; }
62 
64  int GetX() const { return x; }
65 
67  int GetY() const { return y; }
68 
70  int GetWidth() const { return width; }
71 
73  int GetHeight() const { return height; }
74 
76  double GetRot() const { return rotation; }
77 
79  int GetGid() const { return gid; }
80 
82  int GetId() const { return id; }
83 
85  bool IsVisible() const { return visible; }
86 
88  const Tmx::Ellipse *GetEllipse() const { return ellipse; }
89 
91  const Tmx::Polygon *GetPolygon() const { return polygon; }
92 
94  const Tmx::Polyline *GetPolyline() const { return polyline; }
95 
97  const Tmx::Text *GetText() const { return text; }
98 
100  const Tmx::PropertySet &GetProperties() const { return properties; }
101 
102  private:
103  std::string name;
104  std::string type;
105 
106  int x;
107  int y;
108  int width;
109  int height;
110  int gid;
111  int id;
112 
113  double rotation;
114  bool visible;
115 
116  Tmx::Ellipse *ellipse;
117  Tmx::Polygon *polygon;
118  Tmx::Polyline *polyline;
119  Tmx::Text *text;
120 
121  Tmx::PropertySet properties;
122  };
123 }
const Tmx::Text * GetText() const
Get the Text.
Definition: TmxObject.h:97
Class to store an Ellipse of an Object.
Definition: TmxEllipse.h:39
const std::string & GetType() const
Get the type of the object.
Definition: TmxObject.h:61
int GetHeight() const
Get the height of the object, in pixels.
Definition: TmxObject.h:73
const Tmx::Polyline * GetPolyline() const
Get the Polyline.
Definition: TmxObject.h:94
int GetX() const
Get the left side of the object, in pixels.
Definition: TmxObject.h:64
Class to store a Polygon of an Object.
Definition: TmxPolygon.h:43
Class to store a Polyline of an Object.
Definition: TmxPolyline.h:43
bool IsVisible() const
Get the visibility of the object.
Definition: TmxObject.h:85
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 Tmx::Ellipse * GetEllipse() const
Get the ellipse.
Definition: TmxObject.h:88
const std::string & GetName() const
Get the name of the object.
Definition: TmxObject.h:58
int GetWidth() const
Get the width of the object, in pixels.
Definition: TmxObject.h:70
const Tmx::Polygon * GetPolygon() const
Get the Polygon.
Definition: TmxObject.h:91
double GetRot() const
Get the rotation of the object, in degrees.
Definition: TmxObject.h:76
int GetGid() const
Get the Global ID of the tile associated with this object.
Definition: TmxObject.h:79
const Tmx::PropertySet & GetProperties() const
Get the property set.
Definition: TmxObject.h:100
int GetId() const
Get the ID of this object.
Definition: TmxObject.h:82
void Parse(const tinyxml2::XMLNode *objectNode)
Parse an object node.
Definition: TmxObject.cpp:80
int GetY() const
Get the top side of the object, in pixels.
Definition: TmxObject.h:67
Class to store an Text of an Object.
Definition: TmxText.h:62