#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 tbCore::tbString &spriteSheet, 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 |
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) |
| void | SetOrigin (const AnchorLocation &anchor) |
| void | SetOrigin (const float originX, const float originY) |
| float | GetDepth (void) const |
| void | SetDepth (const float newDepth) |
| void | SetScale (const float scale) |
| void | SetScale (const float scaleX, const float scaleY) |
| void | SetRotation (const float rotation) |
| float | GetRotation (void) const |
| void | SetScroll (const float scroll) |
| void | SetScroll (const float scrollX, const float scrollY) |
| bool | IsRelative (void) const |
| virtual void | SetColor (const tbGraphics::Color &newColor) |
| float | GetWidth (void) const |
| float | GetHeight (void) 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) |
| const Color & | GetColor (void) const |
| 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 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 tbCore::tbString & | spriteSheet, |
| 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.
|
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. |
|
protected |
Changes the frame of the Sprite so it can flip to a new frame for AnimatedSprite or other effects from subclasses.