![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <components.hpp>
Public Member Functions | |
| AnimatedSprite ()=default | |
| AnimatedSprite (std::shared_ptr< Window > window) | |
| void | initialize () override |
| void | render (std::shared_ptr< Window >) override |
| void | update (float deltaTime) override |
| void | addAnimation (const Animation &animation) |
| void | removeAnimation (const std::string &name) |
| void | play (const std::string &animation) |
| void | stop () |
| void | pause () |
| const Texture * | getCurrentTexture () const |
| Vector2 | getCurrentSize () const |
| bool | isPlaying () const |
| Frame * | getCurrentFrame () const |
| std::string | getCurrentAnimationName () const |
| Animation * | getCurrentAnimation () const |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
| void | postLoad () |
Public Member Functions inherited from Component | |
| virtual | ~Component ()=default |
| virtual void | physicsUpdate () |
| virtual void | input (InputEvent &event) |
| virtual void | exit () |
| Node * | getNode () const |
| void | setNode (Node *n) |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Attributes | |
| Signal< std::string > | changed |
| Signal< std::string > | finished |
| Signal< std::string > | looped |
| Signal< std::string > | stopped |
| Signal< std::string > | paused |
| bool | flipH = false |
| bool | flipV = false |
| std::map< std::string, Animation > | animations |
| bool | visible = true |
| bool | screenSpace = false |
The AnimatedSprite class allows you to define Animations composed of Frames which will get rendered on screen.
Example usage:
You can start, stop and pause animations:
AnimatedSprites also have a bunch of signals that you can register to callbacks. For example, you can register a callback when the animation is finished!
And, just like regular Sprites, AnimatedSprites have the flipV and flipH attributes. This is useful when animating the sprite!
You can also make AnimatedSprites render using screen space positioning. This can be used for UI elements and things like that:
Make sure to also check out the animated sprite example!
|
default |
|
inline |
| void AnimatedSprite::addAnimation | ( | const Animation & | animation | ) |
| Animation * AnimatedSprite::getCurrentAnimation | ( | ) | const |
| std::string AnimatedSprite::getCurrentAnimationName | ( | ) | const |
| Frame * AnimatedSprite::getCurrentFrame | ( | ) | const |
| Vector2 AnimatedSprite::getCurrentSize | ( | ) | const |
| const Texture * AnimatedSprite::getCurrentTexture | ( | ) | const |
|
overridevirtual |
Reimplemented from Component.
| bool AnimatedSprite::isPlaying | ( | ) | const |
|
inline |
| void AnimatedSprite::pause | ( | ) |
| void AnimatedSprite::play | ( | const std::string & | animation | ) |
|
virtual |
Reimplemented from Component.
| void AnimatedSprite::removeAnimation | ( | const std::string & | name | ) |
|
overridevirtual |
Reimplemented from Component.
|
inline |
| void AnimatedSprite::stop | ( | ) |
|
overridevirtual |
Reimplemented from Component.
| std::map<std::string, Animation> AnimatedSprite::animations |
| Signal<std::string> AnimatedSprite::changed |
| Signal<std::string> AnimatedSprite::finished |
| bool AnimatedSprite::flipH = false |
| bool AnimatedSprite::flipV = false |
| Signal<std::string> AnimatedSprite::looped |
| Signal<std::string> AnimatedSprite::paused |
| bool AnimatedSprite::screenSpace = false |
| Signal<std::string> AnimatedSprite::stopped |
| bool AnimatedSprite::visible = true |