Wasabi
|
#include <WSprite.hpp>
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 |
![]() | |
WBase (class Wasabi *const app, uint32_t ID=0) | |
uint32_t | GetID () const |
std::string | GetName () const |
class Wasabi * | GetAppPtr () const |
void | AddReference () |
void | RemoveReference () |
![]() | |
void | AddEffect (class WEffect *effect, uint32_t bindingSet=0) |
void | RemoveEffect (class WEffect *effect) |
void | RemoveEffect (class WMaterial *material) |
void | ClearEffects () |
class WMaterial * | GetMaterial (class WEffect *effect) |
class WMaterialCollection & | GetMaterials () |
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) | |
![]() | |
void | _AddMaterial (class WMaterial *material) |
virtual void | OnMaterialAdded (class WMaterial *newMaterial) |
Friends | |
class | WSpriteManager |
Additional Inherited Members | |
![]() | |
class Wasabi * | m_app |
uint32_t | m_ID |
std::string | m_name |
![]() | |
std::unordered_map< class WEffect *, class WMaterial * > | m_materialMap |
class WMaterialCollection * | m_materialsCollection |
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.
|
static |
Returns "Sprite" string.
float WSprite::GetAngle | ( | ) | const |
Retrieves the current angle of the sprite.
WVector2 WSprite::GetPosition | ( | ) | const |
Retrieves the position of the sprite.
uint32_t WSprite::GetPriority | ( | ) | const |
Retrieves the current priority of the sprite. See SetPriority().
WVector2 WSprite::GetSize | ( | ) | const |
Retrieves the size of the sprite.
|
overridevirtual |
This function must be implemented by a child class. This is used for debugging, in which a class should return its name.
Implements WBase.
bool WSprite::Hidden | ( | ) | const |
Checks if the sprite is hidden.
void WSprite::Hide | ( | ) |
Hide the sprite.
void WSprite::Move | ( | float | units | ) |
Moves the sprite forward towards the angle its facing, 0 being to the right.
units | Units to move forward by |
void WSprite::Render | ( | class WRenderTarget * | rt | ) |
Renders the sprite. The sprite will not render if its hidden or invalid (see Valid()).
rt | Render target to render to |
material | Material to use to render the sprite |
void WSprite::Rotate | ( | float | fAngle | ) |
Rotates the sprite in the clockwise direction.
fAngle | Angle to rotate by |
void WSprite::SetAngle | ( | float | fAngle | ) |
Sets the angle (clockwise rotation) of the sprite.
fAngle | Angle of the sprite, in degrees |
|
overridevirtual |
|
overridevirtual |
void WSprite::SetPosition | ( | WVector2 | pos | ) |
Sets the position of the sprite in screen-space.
pos | 2D coordinates in screen-space |
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.
priority | New priority to set |
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.
x | The x-coordinate for the center of rotation relative to the position of the sprite |
y | The y-coordinate of the center of rotation relative to the position of the sprite |
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.
center | The center of rotation relative to the position of the sprite |
void WSprite::SetSize | ( | class WImage * | image | ) |
Sets the size of the sprite to the size of an image
image | Image to use its size |
void WSprite::SetSize | ( | WVector2 | size | ) |
Sets the size of the sprite.
size | Width and height of the sprite, in pixels |
void WSprite::Show | ( | ) |
Show the sprite.
|
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).
Implements WBase.
bool WSprite::WillRender | ( | class WRenderTarget * | rt | ) |
Checks whether a call to Render() will cause any rendering (draw call) to happen.