#include <tb_sprite.hpp>
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 tbCore::tbString &spriteSheetName, const tbCore::tbString &spriteName) | |
Sprite (const Sprite &other) | |
virtual | ~Sprite (void) |
Sprite & | operator= (const Sprite &other) |
virtual PixelSpace | GetPixelWidth (void) const override |
virtual PixelSpace | GetPixelHeight (void) const override |
void | SetFlippedHorizontally (bool isFlippedHorizontally) |
void | SetFlippedVertically (bool isFlippedVertically) |
bool | IsFlippedHorizontally (void) const |
bool | IsFlippedVertically (void) const |
Public Member Functions inherited from TurtleBrains::Graphics::Graphic | |
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) |
const tbMath::Vector2 & | GetOrigin (void) const |
void | SetOrigin (const AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero()) |
void | SetOrigin (const float originX, const float originY) |
void | SetOrigin (const tbMath::Vector2 &origin) |
float | GetDepth (void) const |
void | SetDepth (const float newDepth) |
const tbMath::Vector2 & | GetScale (void) const |
void | SetScale (const float scale) |
void | SetScale (const tbMath::Vector2 &scale) |
void | SetScale (const float scaleX, const float scaleY) |
float | GetRotation (void) const |
void | SetRotation (const float rotation) |
void | SetScroll (const float scroll) |
void | SetScroll (const float scrollX, const float scrollY) |
bool | IsRelative (void) const |
const Color & | GetColor (void) const |
virtual void | SetColor (const tbGraphics::Color &newColor) |
float | GetWidth (void) const |
float | GetHeight (void) const |
float | GetScaledWidth (void) const |
float | GetScaledHeight (void) const |
bool | UnstableIsPointContained (const tbMath::Vector2 &point) const |
Protected Member Functions | |
virtual void | OnRender (void) const override |
void | SetSpriteFrame (const SpriteFrame &spriteFrame) |
const SpriteFrame & | GetSpriteFrame (void) const |
Protected Member Functions inherited from TurtleBrains::Graphics::Graphic | |
virtual void | OnUpdate (const float deltaTime) |
virtual void | ApplyTransform (void) const |
virtual void | PopTransform (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 InvalidTexture() 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 tbCore::tbString & | spriteSheetName, |
const tbCore::tbString & | spriteName | ||
) |
Creates an Sprite similar to Sprite(tbGraphics::theSpriteManager.GetSprite("sheet", "sprite")) except more convenient.
spriteSheetName | A name to a SpriteSheet that was loaded during a call to SpriteManager::LoadSpriteSheetFromFile() or SpriteManager::LoadSpriteSheetFromData(). If no SpriteSheet is found with the provided spriteSheetName, an error condition will be triggered. |
spriteName | A name to the sprite data on the specified SpriteSheet which was loaded. If no sprite data is found with the provided spriteName and 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.
|
overridevirtual |
Returns the height of the sprite in pixels.
Reimplemented from TurtleBrains::Graphics::Graphic.
|
overridevirtual |
Returns the width of the sprite in pixels.
Reimplemented from TurtleBrains::Graphics::Graphic.
|
protected |
Returns the current sprite frame to be inspected or used by subclasses.
bool TurtleBrains::Graphics::Sprite::IsFlippedHorizontally | ( | void | ) | const |
Returns true if the sprite is currently flipped horizontally.
bool TurtleBrains::Graphics::Sprite::IsFlippedVertically | ( | void | ) | const |
Returns true if the sprite is currently flipped vertically.
|
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::SetFlippedHorizontally | ( | bool | isFlippedHorizontally | ) |
If you have a directional sprite that you want facing the opposite direction, just call this for the horizontal directions.
True | to flip the sprite the opposite direction, or false to use it as it is existing on the texture. |
void TurtleBrains::Graphics::Sprite::SetFlippedVertically | ( | bool | isFlippedVertically | ) |
If you have a directional sprite that you want facing the opposite direction, just call this for the vertical directions.
True | to flip the sprite upside down from what it is on the texture other false will use the sprite as it exists on the texture. |
|
protected |
Changes the frame of the Sprite so it can flip to a new frame for AnimatedSprite or other effects from subclasses.