|
Sparkle 0.0.1
|
Drives sprite rendering based on registered animations. More...
#include <spk_animation_controller_2d.hpp>


Public Member Functions | |
| AnimationController2D (const std::wstring &p_name, spk::SpriteRenderer2D &p_spriteRenderer) | |
| Builds a controller tied to a sprite renderer. | |
| const spk::SpriteRenderer2D & | spriteRenderer () const |
| Returns the sprite renderer targeted by this controller. | |
| void | setDefaultAnimation (const Animation2D *p_animation) |
| Sets the default animation used when no other is active. | |
| const Animation2D * | defaultAnimation () const |
| Returns the default animation. | |
| void | setAnimationSpeed (float p_speed) |
| Sets the animation playback speed multiplier. | |
| float | animationSpeed () const |
| Returns the animation playback speed multiplier. | |
| void | addAnimation (const std::wstring &p_name, const Animation2D *p_animation, bool p_shouldLoop) |
| Registers an animation with a name. | |
| bool | hasAnimation (const std::wstring &p_name) const |
| Checks whether an animation name is registered. | |
| void | startAnimation (const std::wstring &p_name) |
| Starts a named animation. | |
| void | resetToDefault () |
| Resets playback to the default animation. | |
| void | start () override |
| Starts the controller and initializes animation state. | |
| Public Member Functions inherited from spk::Component2D | |
| Component2D (const std::wstring &p_name) | |
| Builds a 2D component with a name. | |
| Entity2D * | owner () |
| Returns the 2D owner entity. | |
| const Entity2D * | owner () const |
| Returns the 2D owner entity. | |
| Public Member Functions inherited from spk::Component | |
| Component (const std::wstring &p_name) | |
| Builds a component with a name. | |
| ~Component () override | |
| Virtual destructor. | |
| void | setName (const std::wstring &p_name) |
| Sets the component name. | |
| void | setPriority (const int &p_priority) |
| Sets the component priority. | |
| const std::wstring & | name () const |
| Returns the component name. | |
| int | priority () const |
| Returns the component priority. | |
| Entity * | owner () |
| Returns the owning entity. | |
| const Entity * | owner () const |
| Returns the owning entity. | |
| virtual void | awake () |
| Called when the component becomes active. | |
| virtual void | sleep () |
| Called when the component is put to sleep. | |
| virtual void | stop () |
| Called when the component stops. | |
| virtual void | handleGeometryChange (const spk::Extend2D &p_geometry) |
| Handles geometry change events. | |
| virtual void | handlePaintEvent (spk::PaintEvent &p_event) |
| Handles paint events. | |
| virtual void | handleKeyPressEvent (spk::KeyPressEvent &p_event) |
| Handles key press events. | |
| virtual void | handleKeyReleaseEvent (spk::KeyReleaseEvent &p_event) |
| Handles key release events. | |
| virtual void | handleGlyphEvent (spk::GlyphEvent &p_event) |
| Handles glyph input events. | |
| virtual void | handleMousePressEvent (spk::MousePressEvent &p_event) |
| Handles mouse press events. | |
| virtual void | handleMouseReleaseEvent (spk::MouseReleaseEvent &p_event) |
| Handles mouse release events. | |
| virtual void | handleMouseDoubleClickEvent (spk::MouseDoubleClickEvent &p_event) |
| Handles mouse double-click events. | |
| virtual void | handleMouseMotionEvent (spk::MouseMotionEvent &p_event) |
| Handles mouse motion events. | |
| virtual void | handleMouseWheelEvent (spk::MouseWheelEvent &p_event) |
| Handles mouse wheel events. | |
| virtual void | handleEnterResizeModeEvent (spk::EnterResizeModeEvent &p_event) |
| Handles enter resize mode events. | |
| virtual void | handleResizeEvent (spk::ResizeEvent &p_event) |
| Handles resize events. | |
| virtual void | handleExitResizeModeEvent (spk::ExitResizeModeEvent &p_event) |
| Handles exit resize mode events. | |
| virtual void | handleQuitEvent (spk::QuitEvent &p_event) |
| Handles quit events. | |
| virtual void | handleMoveEvent (spk::MoveEvent &p_event) |
| Handles move events. | |
| virtual void | handleFullScreenModeEvent (spk::FullScreenModeEvent &p_event) |
| Handles fullscreen mode events. | |
| virtual void | handleMaximizedModeEvent (spk::MaximizedModeEvent &p_event) |
| Handles maximized mode events. | |
| virtual void | handleFocusEvent (spk::FocusEvent &p_event) |
| Handles focus events. | |
| virtual void | handleUpdateEvent (spk::UpdateEvent &p_event) |
| Handles update events. | |
| Public Member Functions inherited from spk::ActivableObject | |
| ActivableObject () | |
| Builds a deactivated object. | |
| ActivableObject (ActivationStatus p_initial) | |
| Builds with a custom initial activation state. | |
| void | activate () |
| Sets the state to Activated. | |
| void | deactivate () |
| Sets the state to Deactivated. | |
| void | toggle () |
| Toggles between activated and deactivated states. | |
| bool | isActive () const |
| Checks whether the object is currently activated. | |
| Contract | addActivationCallback (const Job &p_callback) |
| Registers a callback executed when the object activates. | |
| Contract | addDeactivationCallback (const Job &p_callback) |
| Registers a callback executed when the object deactivates. | |
| Public Member Functions inherited from spk::StatefulObject< ActivationStatus > | |
| StatefulObject (const ActivationStatus &p_initialState) | |
| Builds with an initial state. | |
| StatefulObject & | operator= (const StatefulObject &p_other)=delete |
| void | setState (const ActivationStatus &p_newState) |
| Sets a new state and triggers callbacks registered for it. | |
| ActivationStatus | state () const |
| Returns the current state. | |
| Contract | addCallback (const ActivationStatus &p_state, const Job &p_callback) |
| Subscribes a callback for a specific state. | |
Additional Inherited Members | |
| Public Types inherited from spk::ActivableObject | |
| using | Contract = StatefulObject<ActivationStatus>::Contract |
| Subscription handle controlling callback lifetime. | |
| using | Job = StatefulObject<ActivationStatus>::Job |
| Callback signature executed on activation state changes. | |
| Public Types inherited from spk::StatefulObject< ActivationStatus > | |
| using | Contract |
| Handle allowing subscribers to manage callback lifetimes. | |
| using | Job |
| Callable invoked when the object transitions to a state. | |
| Protected Member Functions inherited from spk::Component | |
| virtual void | _onGeometryChange (const spk::Extend2D &p_geometry) |
| Handles geometry changes before public callbacks. | |
| virtual void | _onPaintEvent (spk::PaintEvent &p_event) |
| Handles paint events before public callbacks. | |
| virtual void | _onKeyPressEvent (spk::KeyPressEvent &p_event) |
| Handles key press events before public callbacks. | |
| virtual void | _onKeyReleaseEvent (spk::KeyReleaseEvent &p_event) |
| Handles key release events before public callbacks. | |
| virtual void | _onGlyphEvent (spk::GlyphEvent &p_event) |
| Handles glyph input events before public callbacks. | |
| virtual void | _onMousePressEvent (spk::MousePressEvent &p_event) |
| Handles mouse press events before public callbacks. | |
| virtual void | _onMouseReleaseEvent (spk::MouseReleaseEvent &p_event) |
| Handles mouse release events before public callbacks. | |
| virtual void | _onMouseDoubleClickEvent (spk::MouseDoubleClickEvent &p_event) |
| Handles mouse double-click events before public callbacks. | |
| virtual void | _onMouseMotionEvent (spk::MouseMotionEvent &p_event) |
| Handles mouse motion events before public callbacks. | |
| virtual void | _onMouseWheelEvent (spk::MouseWheelEvent &p_event) |
| Handles mouse wheel events before public callbacks. | |
| virtual void | _onEnterResizeModeEvent (spk::EnterResizeModeEvent &p_event) |
| Handles enter resize mode events before public callbacks. | |
| virtual void | _onResizeEvent (spk::ResizeEvent &p_event) |
| Handles resize events before public callbacks. | |
| virtual void | _onExitResizeModeEvent (spk::ExitResizeModeEvent &p_event) |
| Handles exit resize mode events before public callbacks. | |
| virtual void | _onQuitEvent (spk::QuitEvent &p_event) |
| Handles quit events before public callbacks. | |
| virtual void | _onMoveEvent (spk::MoveEvent &p_event) |
| Handles move events before public callbacks. | |
| virtual void | _onFullScreenModeEvent (spk::FullScreenModeEvent &p_event) |
| Handles fullscreen mode events before public callbacks. | |
| virtual void | _onMaximizedModeEvent (spk::MaximizedModeEvent &p_event) |
| Handles maximized mode events before public callbacks. | |
| virtual void | _onFocusEvent (spk::FocusEvent &p_event) |
| Handles focus events before public callbacks. | |
Drives sprite rendering based on registered animations.
| spk::AnimationController2D::AnimationController2D | ( | const std::wstring & | p_name, |
| spk::SpriteRenderer2D & | p_spriteRenderer ) |
Builds a controller tied to a sprite renderer.
| p_name | Component name. |
| p_spriteRenderer | Renderer to update with animation frames. |

| void spk::AnimationController2D::addAnimation | ( | const std::wstring & | p_name, |
| const Animation2D * | p_animation, | ||
| bool | p_shouldLoop ) |
Registers an animation with a name.
| p_name | Name used to start the animation. |
| p_animation | Animation to register. |
| p_shouldLoop | Whether the animation should loop. |
| float spk::AnimationController2D::animationSpeed | ( | ) | const |
Returns the animation playback speed multiplier.
| const Animation2D * spk::AnimationController2D::defaultAnimation | ( | ) | const |
Returns the default animation.
| bool spk::AnimationController2D::hasAnimation | ( | const std::wstring & | p_name | ) | const |
Checks whether an animation name is registered.
| p_name | Animation name. |
| void spk::AnimationController2D::setAnimationSpeed | ( | float | p_speed | ) |
Sets the animation playback speed multiplier.
| p_speed | Speed multiplier. |
| void spk::AnimationController2D::setDefaultAnimation | ( | const Animation2D * | p_animation | ) |
Sets the default animation used when no other is active.
| p_animation | Animation to use as default. |
| const spk::SpriteRenderer2D & spk::AnimationController2D::spriteRenderer | ( | ) | const |
Returns the sprite renderer targeted by this controller.
|
overridevirtual |
Starts the controller and initializes animation state.
Reimplemented from spk::Component.
| void spk::AnimationController2D::startAnimation | ( | const std::wstring & | p_name | ) |
Starts a named animation.
| p_name | Registered animation name. |