|
dEngine
Simple 2D C++ game engine
|
#include <SpriteSheet.h>
Public Member Functions | |
| SpriteSheet (std::string filepath, GameObject &parent) | |
| Constructor. More... | |
| ~SpriteSheet () | |
| Destructor. More... | |
| void | SetCurrentAnimation (std::string name) |
| Set current animation. More... | |
| void | RegisterAnimation (std::string name, int x, int y, int w, int h, int frames) |
| Register new animation. More... | |
| void | DeregisterAnimation (std::string name) |
| Remove animation. More... | |
| bool | HasAnimation (std::string name) |
| Check if spritesheet has an animation. More... | |
| void | Render () override |
| Render the animation. More... | |
| void | Pause (bool pause) |
Public Member Functions inherited from dengine::Component | |
| Component (GameObject &parent) | |
| Create a new component for a gameobject. More... | |
| virtual void | NotifyCollision (GameObject &other) |
| std::string | GetName () |
| Returns the component's name. More... | |
| virtual void | Start () |
| Start the object To be called by the GameObject's Start method. This should be called at the beginning of instantiation. More... | |
| virtual void | Update () |
Private Attributes | |
| std::map< std::string, Animation > | animationCollection |
| SDL_Texture * | sheet |
| std::string | currentAnimation = "" |
| bool | isPaused = false |
Additional Inherited Members | |
Protected Attributes inherited from dengine::Component | |
| GameObject & | parent |
| std::string | name |
A SpriteSheet.
SpriteSheets are used for images that may include multiple depictions or animations, usually based off a single image with many images included. Google "Game Spritesheet" and switch to images to see an example.
| SpriteSheet::SpriteSheet | ( | std::string | filepath, |
| GameObject & | parent | ||
| ) |
Constructor.
Create a Spritesheet object
| filepath | File path to the spritesheet image |
| parent | The parent object of this spritesheet |
| SpriteSheet::~SpriteSheet | ( | ) |
Destructor.
Cleans up and frees resources that were allocated by the spritesheet
| void SpriteSheet::DeregisterAnimation | ( | std::string | name | ) |
Remove animation.
Deregisters an animation, freeing up resources and ensuring animation can no longer be called
| name | Name of the animation |
| bool SpriteSheet::HasAnimation | ( | std::string | name | ) |
Check if spritesheet has an animation.
Determine if a named animation has already been registered
| name | Name of the animation |
| void SpriteSheet::Pause | ( | bool | pause | ) |
Pauses the rendering of an animation
| void SpriteSheet::RegisterAnimation | ( | std::string | name, |
| int | x, | ||
| int | y, | ||
| int | w, | ||
| int | h, | ||
| int | frames | ||
| ) |
Register new animation.
Register an animation from a spritesheet
| name | Name of the animation |
| x | The starting x postion of the first frame of the animation |
| y | The starting y position of the first frame of the animation |
| w | The width of each frame of the animation |
| h | The height of each frame of the animation |
| frames | The total number of frames in the animation |
|
overridevirtual |
Render the animation.
Reimplemented from dengine::Component.
| void SpriteSheet::SetCurrentAnimation | ( | std::string | name | ) |
Set current animation.
Set the current animation to be rendered
| name | The name of a registered animation |
|
private |
Referenced by DeregisterAnimation(), HasAnimation(), RegisterAnimation(), and Render().
|
private |
Referenced by Render(), and SetCurrentAnimation().
|
private |
Referenced by Render(), SpriteSheet(), and ~SpriteSheet().
1.8.13