Wasabi
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
WSprite Class Reference

#include <WSprite.hpp>

Inheritance diagram for WSprite:
WBase WMaterialsStore

Public Member Functions

virtual std::string GetTypeName () const override
 
virtual void SetID (uint32_t newID) override
 
virtual void SetName (std::string newName) override
 
bool WillRender (class WRenderTarget *rt)
 
void Render (class WRenderTarget *rt)
 
void SetPosition (WVector2 pos)
 
void Move (float units)
 
void SetSize (WVector2 size)
 
void SetSize (class WImage *image)
 
void SetAngle (float fAngle)
 
void Rotate (float fAngle)
 
void SetRotationCenter (float x, float y)
 
void SetRotationCenter (WVector2 center)
 
void SetPriority (uint32_t priority)
 
void Show ()
 
void Hide ()
 
bool Hidden () const
 
float GetAngle () const
 
WVector2 GetPosition () const
 
WVector2 GetSize () const
 
uint32_t GetPriority () const
 
virtual bool Valid () const override
 
- Public Member Functions inherited from WBase
 WBase (class Wasabi *const app, uint32_t ID=0)
 
uint32_t GetID () const
 
std::string GetName () const
 
class WasabiGetAppPtr () const
 
void AddReference ()
 
void RemoveReference ()
 
- Public Member Functions inherited from WMaterialsStore
void AddEffect (class WEffect *effect, uint32_t bindingSet=0)
 
void RemoveEffect (class WEffect *effect)
 
void RemoveEffect (class WMaterial *material)
 
void ClearEffects ()
 
class WMaterialGetMaterial (class WEffect *effect)
 
class WMaterialCollectionGetMaterials ()
 

Static Public Member Functions

static std::string _GetTypeName ()
 

Protected Member Functions

 WSprite (Wasabi *const app, uint32_t ID=0)
 
 WSprite (Wasabi *const app, class WEffect *fx, uint32_t bindingSet, uint32_t ID=0)
 
- Protected Member Functions inherited from WMaterialsStore
void _AddMaterial (class WMaterial *material)
 
virtual void OnMaterialAdded (class WMaterial *newMaterial)
 

Friends

class WSpriteManager
 

Additional Inherited Members

- Protected Attributes inherited from WBase
class Wasabim_app
 
uint32_t m_ID
 
std::string m_name
 
- Protected Attributes inherited from WMaterialsStore
std::unordered_map< class WEffect *, class WMaterial * > m_materialMap
 
class WMaterialCollectionm_materialsCollection
 

Detailed Description

Implementation of a sprite. A sprite provides an interface to control the position, orientation, and other properties for an image to be drawn on screen.

Member Function Documentation

◆ _GetTypeName()

static std::string WSprite::_GetTypeName ( )
static

Returns "Sprite" string.

Returns
Returns "Sprite" string

◆ GetAngle()

float WSprite::GetAngle ( ) const

Retrieves the current angle of the sprite.

Returns
The current angle of the sprite

◆ GetPosition()

WVector2 WSprite::GetPosition ( ) const

Retrieves the position of the sprite.

Returns
XY-coordinates of the sprite, in screen-space

◆ GetPriority()

uint32_t WSprite::GetPriority ( ) const

Retrieves the current priority of the sprite. See SetPriority().

Returns
The current priority of the sprite

◆ GetSize()

WVector2 WSprite::GetSize ( ) const

Retrieves the size of the sprite.

Returns
Width and height of the sprite, in pixels

◆ GetTypeName()

virtual std::string WSprite::GetTypeName ( ) const
overridevirtual

This function must be implemented by a child class. This is used for debugging, in which a class should return its name.

Returns
The name of the class

Implements WBase.

◆ Hidden()

bool WSprite::Hidden ( ) const

Checks if the sprite is hidden.

Returns
true if the sprite is hidden, false otherwise

◆ Hide()

void WSprite::Hide ( )

Hide the sprite.

◆ Move()

void WSprite::Move ( float  units)

Moves the sprite forward towards the angle its facing, 0 being to the right.

Parameters
unitsUnits to move forward by

◆ Render()

void WSprite::Render ( class WRenderTarget rt)

Renders the sprite. The sprite will not render if its hidden or invalid (see Valid()).

Parameters
rtRender target to render to
materialMaterial to use to render the sprite

◆ Rotate()

void WSprite::Rotate ( float  fAngle)

Rotates the sprite in the clockwise direction.

Parameters
fAngleAngle to rotate by

◆ SetAngle()

void WSprite::SetAngle ( float  fAngle)

Sets the angle (clockwise rotation) of the sprite.

Parameters
fAngleAngle of the sprite, in degrees

◆ SetID()

virtual void WSprite::SetID ( uint32_t  newID)
overridevirtual

Sets the ID of this object and notifies its manager.

Parameters
newIDNew ID

Implements WBase.

◆ SetName()

virtual void WSprite::SetName ( std::string  newName)
overridevirtual

Sets the name of this object.

Parameters
nameNew name for the object

Implements WBase.

◆ SetPosition()

void WSprite::SetPosition ( WVector2  pos)

Sets the position of the sprite in screen-space.

Parameters
pos2D coordinates in screen-space

◆ SetPriority()

void WSprite::SetPriority ( uint32_t  priority)

Sets the priority of the sprite. Sprites with higher priority will render on top of those with lower priority.

Parameters
priorityNew priority to set

◆ SetRotationCenter() [1/2]

void WSprite::SetRotationCenter ( float  x,
float  y 
)

Sets the center of rotation of the sprite. The default center of rotation is (0,0) meaning the top-left corner.

Parameters
xThe x-coordinate for the center of rotation relative to the position of the sprite
yThe y-coordinate of the center of rotation relative to the position of the sprite

◆ SetRotationCenter() [2/2]

void WSprite::SetRotationCenter ( WVector2  center)

Sets the center of rotation of the sprite. The default center of rotation is (0,0) meaning the top-left corner.

Parameters
centerThe center of rotation relative to the position of the sprite

◆ SetSize() [1/2]

void WSprite::SetSize ( class WImage image)

Sets the size of the sprite to the size of an image

Parameters
imageImage to use its size

◆ SetSize() [2/2]

void WSprite::SetSize ( WVector2  size)

Sets the size of the sprite.

Parameters
sizeWidth and height of the sprite, in pixels

◆ Show()

void WSprite::Show ( )

Show the sprite.

◆ Valid()

virtual bool WSprite::Valid ( ) const
overridevirtual

Checks the validity of the sprite. A sprite is valid if it has a texture and its' size is greater than zero (both width and height).

Returns
true if the sprite is valid, false otherwise

Implements WBase.

◆ WillRender()

bool WSprite::WillRender ( class WRenderTarget rt)

Checks whether a call to Render() will cause any rendering (draw call) to happen.


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