libtmx  0.4.0
an C++11 library for reading TMX files
Public Types | Public Member Functions | List of all members
tmx::Object Class Reference

An object is a geometrical object. More...

#include <tmx/Object.h>

Inheritance diagram for tmx::Object:
Inheritance graph
[legend]

Public Types

enum  Kind {
  RECTANGLE,
  ELLIPSE,
  POLYLINE,
  POLYGON,
  TILE
}
 A kind of geometrical object. More...
 

Public Member Functions

 Object (const Kind kind, unsigned id, const std::string &name, const std::string &type, const Vector2u &origin, double rotation, bool visible)
 Object constructor. More...
 
virtual ~Object ()
 Object destructor. More...
 
Kind getKind () const noexcept
 Get the kind of the object. More...
 
unsigned getId () const noexcept
 Get the id of the object. More...
 
const std::string & getName () const noexcept
 Get the name of the object. More...
 
const std::string & getType () const noexcept
 Get the type of the object. More...
 
unsigned getX () const noexcept
 Get the x coordinate of the origin. More...
 
unsigned getY () const noexcept
 Get the y coordinate of the origin. More...
 
const Vector2ugetOrigin () const noexcept
 Get the origin. More...
 
double getRotation () const noexcept
 Get the rotation of the object. More...
 
bool isVisible () const noexcept
 Tell whether this object is visible. More...
 
bool isRectangle () const noexcept
 Tell whether this object is a rectangle. More...
 
bool isEllipse () const noexcept
 Tell whether this object is an ellipse. More...
 
bool isChain () const noexcept
 Tell whether this object is a chain (polygon or polyline). More...
 
bool isPolyline () const noexcept
 Tell whether this object is a polyline. More...
 
bool isPolygon () const noexcept
 Tell whether this object is a polygon. More...
 
bool isTile () const noexcept
 Tell whether this object is a tile. More...
 
- Public Member Functions inherited from tmx::Component
bool hasProperty (const std::string &key) const noexcept
 Tell if the object has a given property. More...
 
const std::string & getProperty (const std::string &key, const std::string &def) const noexcept
 Get a property value. More...
 
bool addProperty (const std::string &key, const std::string &value)
 Add a property. More...
 

Detailed Description

An object is a geometrical object.

There four kinds of geometrical objects: rectangles, ellipses, polylines and polygons.

Member Enumeration Documentation

A kind of geometrical object.

Enumerator
RECTANGLE 

Rectangle

ELLIPSE 

Ellipse

POLYLINE 

Polyline (open line)

POLYGON 

Polygon (closed line)

TILE 

Tile (image)

Constructor & Destructor Documentation

tmx::Object::Object ( const Kind  kind,
unsigned  id,
const std::string &  name,
const std::string &  type,
const Vector2u origin,
double  rotation,
bool  visible 
)
inline

Object constructor.

virtual tmx::Object::~Object ( )
virtual

Object destructor.

Member Function Documentation

unsigned tmx::Object::getId ( ) const
inlinenoexcept

Get the id of the object.

Returns
the id of the object
Kind tmx::Object::getKind ( ) const
inlinenoexcept

Get the kind of the object.

This may be useful to do some casting.

Returns
the kind of the object
const std::string& tmx::Object::getName ( ) const
inlinenoexcept

Get the name of the object.

Returns
the name of the object
const Vector2u& tmx::Object::getOrigin ( ) const
inlinenoexcept

Get the origin.

The origin is the base point of the object on the map. All other coordinates are computed from this point.

Returns
the origin
double tmx::Object::getRotation ( ) const
inlinenoexcept

Get the rotation of the object.

Returns
the angle of rotation in degrees clockwise
const std::string& tmx::Object::getType ( ) const
inlinenoexcept

Get the type of the object.

Returns
the type of the object.
unsigned tmx::Object::getX ( ) const
inlinenoexcept

Get the x coordinate of the origin.

Returns
the x coordinate of the origin
unsigned tmx::Object::getY ( ) const
inlinenoexcept

Get the y coordinate of the origin.

Returns
the y coordinate of the origin
bool tmx::Object::isChain ( ) const
inlinenoexcept

Tell whether this object is a chain (polygon or polyline).

Returns
true if the object is a chain
bool tmx::Object::isEllipse ( ) const
inlinenoexcept

Tell whether this object is an ellipse.

Returns
true if the object is an ellipse
bool tmx::Object::isPolygon ( ) const
inlinenoexcept

Tell whether this object is a polygon.

Returns
true if the object is a polygon
bool tmx::Object::isPolyline ( ) const
inlinenoexcept

Tell whether this object is a polyline.

Returns
true if the object is a polyline
bool tmx::Object::isRectangle ( ) const
inlinenoexcept

Tell whether this object is a rectangle.

Returns
true if the object is a rectangle
bool tmx::Object::isTile ( ) const
inlinenoexcept

Tell whether this object is a tile.

Returns
true if the object is a tile
bool tmx::Object::isVisible ( ) const
inlinenoexcept

Tell whether this object is visible.

Returns
true if the object is visible