#include <tb_sprite.h>
Public Member Functions | |
Sprite (const SpriteFrame &spriteFrame) | |
Sprite (const tbCore::tbString &textureFile, const PixelSpace &frameX=0, const PixelSpace &frameY=0, const PixelSpace &frameWidth=0, const PixelSpace &frameHeight=0) | |
Sprite (const TextureHandle &textureHandle, const PixelSpace &frameX=0, const PixelSpace &frameY=0, const PixelSpace &frameWidth=0, const PixelSpace &frameHeight=0) | |
Sprite (const Sprite &other) | |
virtual | ~Sprite (void) |
Sprite & | operator= (const Sprite &other) |
void | SetOrigin (const AnchorLocation &anchor) |
void | SetOrigin (const float originX, const float originY) |
void | SetScale (const float scale) |
void | SetScale (const float scaleX, const float scaleY) |
void | SetRotation (const float rotation) |
![]() | |
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 | OnRender (void) const override |
void | SetSpriteFrame (const SpriteFrame &spriteFrame) |
const SpriteFrame & | GetSpriteFrame (void) const |
![]() | |
virtual void | OnUpdate (const float deltaTime) |
const Color & | GetColor (void) const |
The Sprite is likely the most common Graphic object used when creating a two-dimensional game. The Sprite contains a little information about the Texture and a rectangle on that texture that describes what should be rendered by the Sprite.
|
explicit |
Constructs a Sprite object with the given SpriteFrame which contains the texture and location size of the sprite.
|
explicit |
Construct a sprite from a filepath of a texture with a given frame location and size.
textureFile | The filepath of a texture to load into the texture manager, if it isn't already, and use as the texture for the sprites frame. |
frameX | The location of the left edge of the sprites frame in pixels from the left edge of the texture. |
frameY | The location of the top edge of the sprites frame in pixels from the top edge of the texture. |
frameWidth | The width of the sprite frame in pixels, frameWidth + frameX must not exceed texture width, or an error condition will be triggered. |
frameHeight | The height of the sprite frame in pixels, frameHeight + frameY must not exceed texture height, or an error condition will be triggered. |
|
explicit |
Construct a sprite from a handle of an already loaded texture given a frame location and size.
textureHandle | The handle of the loaded texture, cannot be kInvalidTexture or an error condition will be triggered. |
frameX | The location of the left edge of the sprites frame in pixels from the left edge of the texture. |
frameY | The location of the top edge of the sprites frame in pixels from the top edge of the texture. |
frameWidth | The width of the sprite frame in pixels, frameWidth + frameX must not exceed texture width, or an error condition will be triggered. |
frameHeight | The height of the sprite frame in pixels, frameHeight + frameY must not exceed texture height, or an error condition will be triggered. |
TurtleBrains::Graphics::Sprite::Sprite | ( | const Sprite & | other | ) |
Construct a sprite from another spriute, copying the sprites frame, color, scaling and other properties.
other | The sprite to copy and mimic. |
|
virtual |
Destroys a sprite object, which doesn't do any heavy lifting at this time.
|
protected |
Returns the current sprite frame to be inspected or used by subclasses.
|
overrideprotectedvirtual |
Actually performs the rendering of the sprite to the screen with OpenGL.
Implements TurtleBrains::Graphics::Graphic.
Set a sprite object to be the show the same sprite frame, color, scaling, origin and all other properties copied from the other sprite.
other | The sprite to copy and mimic. |
void TurtleBrains::Graphics::Sprite::SetOrigin | ( | const AnchorLocation & | anchor | ) |
Sets the origin or a hotspot of the sprite. This is an offset where the sprite will be positioned by and rotated around. The AnchorLocation will describe where the origin offset with a 9 locations, the four corners, and center points of each edge.
|
inline |
Sets the origin or a hotspot of the sprite. This is an offset where the sprite will be positioned by and rotated around.
|
inline |
Set the rotation/orientation of the sprite so it can rotate around the game world and animate things such as windmills, tires, etc.
rotation | The angle in degrees of the sprite, positive values rotate clockwise. |
|
inline |
Changes the scaling of the sprite uniformly on each axis.
scale | The amount of scaling to apply, 1.0 is normal scale, 0.5 is half size and 2.0 is double. |
|
inline |
Changes the scaling of the sprite on each axis separately.
scaleX | The amount of scaling to apply on the X-axis, 1.0 is normal scale, 0.5 is half size. |
scaleY | The amount of scaling to apply on the Y-axis, 1.0 is normal scale, 2.0 is double size. |
|
protected |
Changes the frame of the Sprite so it can flip to a new frame for AnimatedSprite or other effects from subclasses.