#include <tb_graphic.h>
Public Member Functions | |
Graphic (void) | |
Graphic (const Graphic &other) | |
virtual | ~Graphic (void) |
bool | IsActive (void) const |
void | SetActive (const bool isActive) |
void | Update (const float deltaTime) |
bool | IsVisible (void) const |
void | SetVisible (const bool isVisible) |
void | Render (void) const |
const tbMath::Vector2 & | GetPosition (void) const |
void | SetPosition (const float x, const float y) |
void | SetPosition (const tbMath::Vector2 &position) |
float | GetDepth (void) const |
void | SetDepth (const float newDepth) |
bool | IsRelative (void) const |
virtual void | SetColor (const tbGraphics::Color &newColor) |
Protected Member Functions | |
virtual void | OnUpdate (const float deltaTime) |
virtual void | OnRender (void) const =0 |
const Color & | GetColor (void) const |
The Graphic is an abstract interface for Text, Sprite and other graphical objects that can be updated and displayed.
TurtleBrains::Graphics::Graphic::Graphic | ( | void | ) |
Constructs a Graphic object that starts out active and visible with a position of (0.0f, 0.0f) and depth at 0.0f.
TurtleBrains::Graphics::Graphic::Graphic | ( | const Graphic & | other | ) |
|
virtual |
Destroys the Graphic object by doing nothing since no resources need to be cleaned up.
|
protected |
Returns the color of the Graphic which defaults to Color::kWhite but can be changed with SetColor().
float TurtleBrains::Graphics::Graphic::GetDepth | ( | void | ) | const |
Returns the depth, Z value, of the Graphic object.
const tbMath::Vector2& TurtleBrains::Graphics::Graphic::GetPosition | ( | void | ) | const |
Returns the position of the sprite as a Vector2 object.
bool TurtleBrains::Graphics::Graphic::IsActive | ( | void | ) | const |
Returns true if the Graphic is currently active and needing to be updated, or false if the OnUpdate() calls should be skipped.
bool TurtleBrains::Graphics::Graphic::IsRelative | ( | void | ) | const |
This will return true if the Graphic object is relative to it's parent object, such as the contained GraphicList. Currently all Graphics are always relative, although this may be updated in future versions of TurtleBrains.
bool TurtleBrains::Graphics::Graphic::IsVisible | ( | void | ) | const |
Returns true if the Graphic is currently visible and needing to be displayed, or false if the OnRender() calls should be skipped.
|
protectedpure virtual |
This must be overridden by a subclass to actually display the Graphic on the screen. The function will be invoked when Render() is called and the object IsVisible().
Implemented in TurtleBrains::Graphics::Sprite, TurtleBrains::Game::Entity, TurtleBrains::Game::TileSystem, TurtleBrains::Graphics::Text, TurtleBrains::Game::GameScene, and TurtleBrains::Graphics::GraphicList.
|
protectedvirtual |
This should be overridden by a subclass if it needs to perform any updates per frame before displaying / rendering a new frame. This function will be invoked when Update() is called and the object IsActive().
Reimplemented in TurtleBrains::Graphics::AnimatedSprite, TurtleBrains::Game::Entity, TurtleBrains::Game::EntityManager, TurtleBrains::Game::GameScene, and TurtleBrains::Graphics::GraphicList.
void TurtleBrains::Graphics::Graphic::Render | ( | void | ) | const |
First checks to see if the object IsVisible() and calls OnRender() if it is. If the object is not visible nothing happens.
void TurtleBrains::Graphics::Graphic::SetActive | ( | const bool | isActive | ) |
Sets a flag that when false causes the Graphic to skip the OnUpdate() calls and when true will proceed with the OnUpdate() calls. Defaults to true, may lead to better performance if false when the object does not need to be updated.
|
virtual |
Change the color of the sprite so it can fade in/out with alpha, or modify the color for other effects.
Reimplemented in TurtleBrains::Graphics::GraphicList.
void TurtleBrains::Graphics::Graphic::SetDepth | ( | const float | newDepth | ) |
Sets the depth of the graphic object which should be within a range of -1.0f for objects far in the background and 1.0f for the objects nearest to the camera. The default value is 0.0f.
newDepth | The depth of the Graphic object, smaller being farther away and larger being closer to the camera. |
void TurtleBrains::Graphics::Graphic::SetPosition | ( | const float | x, |
const float | y | ||
) |
Sets the position of the object to the x and y location in world space.
x | The position in the world along the worlds X-axis. 0 being the origin, by default the world X-axis is horizontal with 0 being the left edge of the screen and positive numbers toward the right. |
y | The position in the world along the worlds Y-axis. 0 being the origin, by default the world Y-axis is vertical with 0 being the top edge of the screen and positive numbers toward the bottom. |
void TurtleBrains::Graphics::Graphic::SetPosition | ( | const tbMath::Vector2 & | position | ) |
Sets the position of the object to the location in world space with the given x and y components of the Vector2.
position | Where in the world along the each axis the Graphic should be placed. By default the world X-axis is horizontal with 0 being the left edge of the screen and positive numbers toward the right and the Y-axis is vertical with 0 being the top edge of the screen and positive numbers toward the bottom. |
void TurtleBrains::Graphics::Graphic::SetVisible | ( | const bool | isVisible | ) |
Sets a flag that when false causes the Graphic to skip the OnRender() calls and when true will proceed with the OnRender() calls. Defaults to true, may lead to better performance if false when the object does not need to be displayed.
void TurtleBrains::Graphics::Graphic::Update | ( | const float | deltaTime | ) |
First checks to see if the object IsActive() and calls OnUpdate() if it is. If the object is not active nothing happens.