Meteor2D  dev internal
Meteor is a lightweight 2D game engine.
Loading...
Searching...
No Matches
meteor::MSpatialEntity Class Reference

Spatial Entity is the base entity for all types present in scene. This entity keeps track of spatial data within a scene. new instance when not given a parent, will sit at the root of the active scene. More...

#include <spatial.h>

Inheritance diagram for meteor::MSpatialEntity:

Public Member Functions

 MSpatialEntity ()
 Default constructor, instantiates at root level.
 
 MSpatialEntity (MSpatialEntity *parent)
 Parameterised constructor.
 
SVector2 getPosition ()
 
SVector2 getLocalPosition ()
 
void setLocalPosition (float x, float y)
 Sets local position of the entity.
 
void setLocalPosition (SVector2 pos)
 Sets local position of the entity.
 
float getRotation ()
 
float getLocalRotation ()
 
void setLocalRotation (float localRotation)
 Sets local rotation of the entity in x-axis.
 
SVector2 getLocalScale ()
 
void setLocalScale (float x, float y)
 Sets local scale.
 
void setLocalScale (SVector2 scale)
 brief Sets local scale
 
MSpatialEntitygetParent ()
 
std::vector< MSpatialEntity * > * getChildren ()
 
void addChild (MSpatialEntity *entity)
 Adds a child to this entity.
 
void removeChild (MSpatialEntity *entity)
 Remove a child from this entity.
 
template<typename T >
T * find (std::string name)
 Recursively searches for a SpatialEntity within this sub-tree.
 
virtual void onStart ()
 
virtual void onUpdate (float deltaTime)
 
virtual void onExit ()
 
- Public Member Functions inherited from meteor::MEntity
virtual bool equals (MEntity *other)
 Checks equality between two entities.
 
std::string getName ()
 
void setName (std::string name)
 Sets name of entity.
 
virtual std::string toString ()
 Get this object as a string.
 

Protected Member Functions

void updatePositions ()
 
void updateRotations ()
 
void updateScale ()
 
void updateChildren (float deltaTime)
 

Protected Attributes

SVector2 localPosition
 
SVector2 localScale
 
SVector2 position
 
float rotation
 
float localRotation
 
MSpatialEntityparent = NULL
 
std::vector< MSpatialEntity * > * children = NULL
 
- Protected Attributes inherited from meteor::MEntity
std::string name
 

Detailed Description

Spatial Entity is the base entity for all types present in scene. This entity keeps track of spatial data within a scene. new instance when not given a parent, will sit at the root of the active scene.

Constructor & Destructor Documentation

◆ MSpatialEntity()

meteor::MSpatialEntity::MSpatialEntity ( MSpatialEntity * parent)

Parameterised constructor.

Parameters
parentParent entity for this child.

Member Function Documentation

◆ addChild()

void meteor::MSpatialEntity::addChild ( MSpatialEntity * entity)

Adds a child to this entity.

Parameters
entityChild to add.

◆ find()

template<typename T >
T * meteor::MSpatialEntity::find ( std::string name)
inline

Recursively searches for a SpatialEntity within this sub-tree.

Template Parameters
Ttype of Entity to return, needs to be child of SpatialEntity.
Parameters
nameName of entity to search for.
Returns
Reference to SpatialEntity.

◆ getChildren()

std::vector< MSpatialEntity * > * meteor::MSpatialEntity::getChildren ( )
inline
Returns
List of children of the entity.

◆ getLocalPosition()

SVector2 meteor::MSpatialEntity::getLocalPosition ( )
inline
Returns
Local position of this entity.

◆ getLocalRotation()

float meteor::MSpatialEntity::getLocalRotation ( )
inline
Returns
Local rotation of this entity in x-axis

◆ getLocalScale()

SVector2 meteor::MSpatialEntity::getLocalScale ( )
inline
Returns
Local scale of this entity

◆ getParent()

MSpatialEntity * meteor::MSpatialEntity::getParent ( )
inline
Returns
Immediate parent of this entity

◆ getPosition()

SVector2 meteor::MSpatialEntity::getPosition ( )
inline
Returns
World position of this entity

◆ getRotation()

float meteor::MSpatialEntity::getRotation ( )
inline
Returns
World rotation of this entity in x-axis

◆ removeChild()

void meteor::MSpatialEntity::removeChild ( MSpatialEntity * entity)

Remove a child from this entity.

Parameters
entityChild to remove.

◆ setLocalPosition() [1/2]

void meteor::MSpatialEntity::setLocalPosition ( float x,
float y )
inline

Sets local position of the entity.

Parameters
xx-component of the position
yy-component of the position

◆ setLocalPosition() [2/2]

void meteor::MSpatialEntity::setLocalPosition ( SVector2 pos)
inline

Sets local position of the entity.

Parameters
posposition as a Vector2

◆ setLocalRotation()

void meteor::MSpatialEntity::setLocalRotation ( float localRotation)
inline

Sets local rotation of the entity in x-axis.

Parameters
localRotationrotation in x-axis (0-360);

◆ setLocalScale() [1/2]

void meteor::MSpatialEntity::setLocalScale ( float x,
float y )
inline

Sets local scale.

Parameters
xx-component of the scale
yy-component of the scale

◆ setLocalScale() [2/2]

void meteor::MSpatialEntity::setLocalScale ( SVector2 scale)
inline

brief Sets local scale

Parameters
scaleScale as a Vector2