Uranus  1.0.1.0
Uranus is a GameEngine written in C++
Loading...
Searching...
No Matches
tson::Object Class Reference
Collaboration diagram for tson::Object:
[legend]

Public Member Functions

 Object (IJson &json, tson::Map *map)
 
template<typename T >
get (const std::string &name)
 
tson::TiledClassgetClass ()
 
const std::string & getClassType () const
 
TileFlipFlags getFlipFlags () const
 
uint32_t getGid () const
 
int getId () const
 
const std::string & getName () const
 
ObjectType getObjectType () const
 
const std::vector< tson::Vector2i > & getPolygons () const
 
const std::vector< tson::Vector2i > & getPolylines () const
 
const Vector2igetPosition () const
 
tson::PropertygetProp (const std::string &name)
 
PropertyCollectiongetProperties ()
 
float getRotation () const
 
const Vector2igetSize () const
 
const std::string & getTemplate () const
 
const TextgetText () const
 
const std::string & getType () const
 
bool hasFlipFlags (TileFlipFlags flags)
 
bool isEllipse () const
 
bool isPoint () const
 
bool isVisible () const
 
bool parse (IJson &json, tson::Map *map)
 

Private Member Functions

void setObjectTypeByJson (IJson &json)
 

Private Attributes

std::shared_ptr< tson::TiledClassm_class {}
 
bool m_ellipse {}
 
tson::TileFlipFlags m_flipFlags = TileFlipFlags::None
 
uint32_t m_gid {}
 
int m_id {}
 
tson::Mapm_map {nullptr}
 
std::string m_name
 
ObjectType m_objectType = ObjectType::Undefined
 
bool m_point {}
 
std::vector< tson::Vector2im_polygon
 
std::vector< tson::Vector2im_polyline
 
tson::Vector2i m_position
 
tson::PropertyCollection m_properties
 
float m_rotation {}
 
tson::Vector2i m_size
 
std::string m_template
 
tson::Text m_text
 
std::string m_type
 
bool m_visible {}
 

Constructor & Destructor Documentation

◆ Object()

tson::Object::Object ( IJson json,
tson::Map map 
)
inlineexplicit

Parses a json Tiled object

Parameters
json

Member Function Documentation

◆ get()

template<typename T >
T tson::Object::get ( const std::string &  name)
inline

A shortcut for getting a property. Alternative to getProperties().getValue<T>("<name>")

Template Parameters
TThe template value
Parameters
nameName of the property
Returns
The actual value, if it exists. Otherwise: The default value of the type.

◆ getClass()

tson::TiledClass * tson::Object::getClass ( )
inline

Gets the class information for the 'type'/'class' This may only give a valid result if the map is loaded through a tson::Project

Returns
a tson::TiledClass object if related map was loaded through tson::Project

◆ getClassType()

const std::string & tson::Object::getClassType ( ) const
inline

'class': String assigned to class field in editor This was renamed from 'type' to 'class' in Tiled v1.9

Returns

◆ getFlipFlags()

tson::TileFlipFlags tson::Object::getFlipFlags ( ) const
inline

Get all flip flags

Returns

◆ getGid()

uint32_t tson::Object::getGid ( ) const
inline

'gid': GID, only if object comes from a Tilemap

Returns

◆ getId()

int tson::Object::getId ( ) const
inline

'id': Incremental id - unique across all objects

Returns

◆ getName()

const std::string & tson::Object::getName ( ) const
inline

'name': String assigned to name field in editor

Returns

◆ getObjectType()

tson::ObjectType tson::Object::getObjectType ( ) const
inline

Gets what type of object this is.

Returns

◆ getPolygons()

const std::vector< tson::Vector2i > & tson::Object::getPolygons ( ) const
inline

'polygon': A list of x,y coordinates in pixels. If this is a Polygon type, this function will return the points used to create it

Returns

◆ getPolylines()

const std::vector< tson::Vector2i > & tson::Object::getPolylines ( ) const
inline

'polyline': A list of x,y coordinates in pixels If this is a Polyline type, this function will return the points used to create it

Returns

◆ getPosition()

const tson::Vector2i & tson::Object::getPosition ( ) const
inline

'x' and 'y': coordinate in pixels

Returns

◆ getProp()

tson::Property * tson::Object::getProp ( const std::string &  name)
inline

Shortcut for getting a property object. Alternative to getProperties().getProperty("<name>");

Parameters
nameName of the property
Returns

◆ getProperties()

tson::PropertyCollection & tson::Object::getProperties ( )
inline

'properties': A list of properties (name, value, type).

Returns

◆ getRotation()

float tson::Object::getRotation ( ) const
inline

'rotation': Angle in degrees clockwise

Returns

◆ getSize()

const tson::Vector2i & tson::Object::getSize ( ) const
inline

x = 'width' (Width in pixels), y = 'height' (Height in pixels). Ignored if using a gid.)

Returns

◆ getTemplate()

const std::string & tson::Object::getTemplate ( ) const
inline

'template': Reference to a template file, in case object is a template instance

Returns

◆ getText()

const tson::Text & tson::Object::getText ( ) const
inline

'type': String assigned to type field in editor

Returns

◆ getType()

const std::string & tson::Object::getType ( ) const
inline

'type': String assigned to type field in editor This was renamed to 'class' in Tiled v1.9

Returns

◆ hasFlipFlags()

bool tson::Object::hasFlipFlags ( TileFlipFlags  flags)
inline
Parameters
flagsWhich flags to check for. Several flags can be checked at once using the bitwise or operator. Example: hasFlipFlags(TileFlipFlags::Vertically | TileFlipFlags::Horizontally)
Returns
true if the flag(s) specified are set

◆ isEllipse()

bool tson::Object::isEllipse ( ) const
inline

'ellipse': Used to mark an object as an ellipse

Returns

◆ isPoint()

bool tson::Object::isPoint ( ) const
inline

'point': Used to mark an object as a point

Returns
true if the object is of type point

◆ isVisible()

bool tson::Object::isVisible ( ) const
inline

Declared in tileson_forward.hpp

'visible': Whether object is shown in editor.

Returns

◆ parse()

bool tson::Object::parse ( IJson json,
tson::Map map 
)
inline

Parses a json Tiled object and autoamtically determines the object type based on the data presented. Call getObjectType() to see what object type it is.

Parameters
json
Returns
true if all mandatory fields was found. false otherwise.

◆ setObjectTypeByJson()

void tson::Object::setObjectTypeByJson ( IJson json)
inlineprivate

Sets an object type based on json data.

Parameters
json

Field Documentation

◆ m_ellipse

bool tson::Object::m_ellipse {}
private

Says with object type this is

◆ m_flipFlags

tson::TileFlipFlags tson::Object::m_flipFlags = TileFlipFlags::None
private

'x' and 'y': coordinate in pixels

◆ m_gid

uint32_t tson::Object::m_gid {}
private

'ellipse': Used to mark an object as an ellipse

◆ m_id

int tson::Object::m_id {}
private

x = 'width' (Width in pixels), y = 'height' (Height in pixels). Ignored if using a gid.)

◆ m_map

tson::Map* tson::Object::m_map {nullptr}
private

Resolved using bit 32, 31 and 30 from gid

◆ m_name

std::string tson::Object::m_name
private

'id': Incremental id - unique across all objects

◆ m_point

bool tson::Object::m_point {}
private

'name': String assigned to name field in editor

◆ m_polygon

std::vector<tson::Vector2i> tson::Object::m_polygon
private

'point': Used to mark an object as a point

◆ m_polyline

std::vector<tson::Vector2i> tson::Object::m_polyline
private

'polygon': A list of x,y coordinates in pixels

◆ m_position

tson::Vector2i tson::Object::m_position
private

'visible': Whether object is shown in editor.

◆ m_properties

tson::PropertyCollection tson::Object::m_properties
private

'polyline': A list of x,y coordinates in pixels

◆ m_rotation

float tson::Object::m_rotation {}
private

'properties': A list of properties (name, value, type).

◆ m_size

tson::Vector2i tson::Object::m_size
private

'gid': GID, only if object comes from a Tilemap

◆ m_template

std::string tson::Object::m_template
private

'rotation': Angle in degrees clockwise

◆ m_text

tson::Text tson::Object::m_text
private

'template': Reference to a template file, in case object is a template instance

◆ m_type

std::string tson::Object::m_type
private

first: 'text' second: 'wrap'

◆ m_visible

bool tson::Object::m_visible {}
private

'type': String assigned to type field in editor


The documentation for this class was generated from the following file: