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

This entity enables sprite rendering in meteor. More...

#include <sprite2d.h>

Inheritance diagram for meteor::MSprite2D:

Public Member Functions

 MSprite2D (std::string texPath, ERenderLayer layer, uint8_t sortingOrder)
 constructor
 
 MSprite2D (MTexture *texture, ERenderLayer layer, uint8_t sortingOrder)
 constructor
 
void onUpdate (float deltaTime) override
 
void onExit () override
 
void setPivot (SVector2 normVal)
 Set the pivot of the sprite.
 
SVector2 getPivot ()
 Get the pivot of the sprite.
 
- Public Member Functions inherited from meteor::MSpatialEntity
 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 ()
 
- 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.
 

Additional Inherited Members

- Protected Member Functions inherited from meteor::MSpatialEntity
void updatePositions ()
 
void updateRotations ()
 
void updateScale ()
 
void updateChildren (float deltaTime)
 
- Protected Attributes inherited from meteor::MSpatialEntity
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

This entity enables sprite rendering in meteor.

Constructor & Destructor Documentation

◆ MSprite2D() [1/2]

meteor::MSprite2D::MSprite2D ( std::string texPath,
ERenderLayer layer,
uint8_t sortingOrder )

constructor

Parameters
texPathPath to sprite image, relative path evaulated to resS\img\texPath
layerRendering layer
sortingOrderSorting order within the layer

◆ MSprite2D() [2/2]

meteor::MSprite2D::MSprite2D ( MTexture * texture,
ERenderLayer layer,
uint8_t sortingOrder )

constructor

Parameters
textureTexture reference for sprite
layerRendering layer
sortingOrderSorting order within the layer

Member Function Documentation

◆ getPivot()

SVector2 meteor::MSprite2D::getPivot ( )
inline

Get the pivot of the sprite.

Returns
Normalised Vector2

◆ onExit()

void meteor::MSprite2D::onExit ( )
overridevirtual

Reimplemented from meteor::MSpatialEntity.

◆ onUpdate()

void meteor::MSprite2D::onUpdate ( float deltaTime)
overridevirtual

Reimplemented from meteor::MSpatialEntity.

◆ setPivot()

void meteor::MSprite2D::setPivot ( SVector2 normVal)
inline

Set the pivot of the sprite.

Parameters
normValNormalised vector2