Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Graphics::TileAnimator< StateType > Class Template Reference

Class for tile animator. More...

#include <tile_animator.hpp>

Inheritance diagram for Graphics::TileAnimator< StateType >:
Component Cloneable< TileAnimator< StateType > > Events::Subject Events::Observer

Public Member Functions

 TileAnimator ()=delete
 
 TileAnimator (const unsigned int tileset_width, const unsigned int tileset_height, const unsigned int tile_width_pixels, const unsigned int tile_height_pixels)
 TileAnimator Constructor. More...
 
void setStartingState (const StateType &state)
 Sets the starting state. More...
 
void addFrameFront (const StateType &state, const glm::ivec2 &frame_pos, const unsigned int frame_time, bool set_current=false)
 Adds a frame to the front. More...
 
void addFrameBack (const StateType &state, const glm::ivec2 &frame_pos, const unsigned int frame_time, bool set_current=false)
 Adds a frame to the back. More...
 
void popFrameFront (const StateType &state)
 Pops a frame from the front. More...
 
void popFrameBack (const StateType &state)
 Pops a frame from the back. More...
 
void triggerAnimation (const StateType &state)
 Triggers animation of state. More...
 
virtual std::string className () const noexceptoverride
 Returns a string representing the class name. More...
 
virtual void onStart () override
 Called when the engine starts and when a new scene is loaded. More...
 
virtual bool onUpdate (const double delta) override
 Called every engine loop. More...
 
virtual void onDestroy () override
 Called when the engine is shutting down. More...
 
void handleQueuedEvent (std::shared_ptr< Events::Event > event) override
 HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More...
 
void onNotifyNow (std::shared_ptr< Events::Event > event) override
 When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More...
 
virtual unsigned long long getValueForSorting () const noexceptoverride
 Gets the value for sorting. More...
 
virtual void log (el::base::type::ostream_t &os) const
 
- Public Member Functions inherited from Component
 Component ()
 Component constructor. More...
 
void setTransform (std::shared_ptr< Transform > transform)
 Sets the transform. More...
 
std::shared_ptr< TransformgetTransform () const noexcept
 Gets the transform. More...
 
void setActive (const bool active) noexcept
 Sets the component active or inactive. More...
 
bool isActive () const noexcept
 Determines if active. More...
 
unsigned int getId () const noexcept
 Gets the identifier. More...
 
virtual std::string to_string () const noexcept
 Returns a string representation of the object. More...
 
bool operator< (Component &other) noexcept
 Operator < using getValueForSorting. More...
 
virtual ~Component ()
 Destroys the object. More...
 
- Public Member Functions inherited from Events::Subject
virtual ~Subject ()=default
 
virtual void notify (std::shared_ptr< Event > event)
 notify is used to tell observers of an event. More...
 
virtual void notifyNow (std::shared_ptr< Event > event)
 notifyNow is used to tell observers of an event as an interrupt. More...
 
virtual void addObserver (std::shared_ptr< Observer > observer)
 Adds an observer. More...
 
virtual void removeObserver (std::shared_ptr< Observer > observer)
 Removes an observer. More...
 
- Public Member Functions inherited from Events::Observer
virtual ~Observer ()
 
void onNotify (std::shared_ptr< Event > event)
 When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More...
 
void processEventQueue ()
 This should be called once ever loop for every Observer to properly use queued events. More...
 
- Public Member Functions inherited from Cloneable< TileAnimator< StateType > >
virtual ~Cloneable ()
 
std::shared_ptr< TileAnimator
< StateType > > 
clone ()
 

Static Public Member Functions

static std::shared_ptr
< TileAnimator< StateType > > 
create (const unsigned int tileset_width, const unsigned int tileset_height, const unsigned int tile_width, const unsigned int tile_height)
 Factory function for TileAnimator. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Events::Observer
std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 
- Protected Attributes inherited from Component
std::weak_ptr< Entityentity
 
std::shared_ptr< Transformtransform
 
bool active
 
unsigned int id
 
- Static Protected Attributes inherited from Component
static unsigned int next_id = 0
 

Detailed Description

template<typename StateType>
class Graphics::TileAnimator< StateType >

Class for tile animator.

Constructor & Destructor Documentation

template<typename StateType>
Graphics::TileAnimator< StateType >::TileAnimator ( )
delete
template<typename StateType>
Graphics::TileAnimator< StateType >::TileAnimator ( const unsigned int  tileset_width,
const unsigned int  tileset_height,
const unsigned int  tile_width_pixels,
const unsigned int  tile_height_pixels 
)
inline

TileAnimator Constructor.

Parameters
[in]tileset_widthThe tileset width
[in]tileset_heightThe tileset height
[in]tile_width_pixelsThe tile width pixels
[in]tile_height_pixelsThe tile height pixels

Member Function Documentation

template<typename StateType>
void Graphics::TileAnimator< StateType >::addFrameBack ( const StateType &  state,
const glm::ivec2 &  frame_pos,
const unsigned int  frame_time,
bool  set_current = false 
)
inline

Adds a frame to the back.

Parameters
[in]stateThe state
[in]frame_posThe frame position
[in]frame_timeThe frame time
[in]set_currentThe set current
template<typename StateType>
void Graphics::TileAnimator< StateType >::addFrameFront ( const StateType &  state,
const glm::ivec2 &  frame_pos,
const unsigned int  frame_time,
bool  set_current = false 
)
inline

Adds a frame to the front.

Parameters
[in]stateThe state
[in]frame_posThe frame position
[in]frame_timeThe frame time
[in]set_currentThe set current
template<typename StateType>
virtual std::string Graphics::TileAnimator< StateType >::className ( ) const
inlineoverridevirtualnoexcept

Returns a string representing the class name.

Returns
The class name

Reimplemented from Component.

template<typename StateType>
static std::shared_ptr<TileAnimator<StateType> > Graphics::TileAnimator< StateType >::create ( const unsigned int  tileset_width,
const unsigned int  tileset_height,
const unsigned int  tile_width,
const unsigned int  tile_height 
)
inlinestatic

Factory function for TileAnimator.

Parameters
[in]tileset_widthThe tileset width
[in]tileset_heightThe tileset height
[in]tile_widthThe tile width
[in]tile_heightThe tile height
Returns
Newly created TileAnimator
template<typename StateType>
virtual unsigned long long Graphics::TileAnimator< StateType >::getValueForSorting ( ) const
inlineoverridevirtualnoexcept

Gets the value for sorting.

Returns
The value for sorting.

Implements Component.

References Component::getId().

template<typename StateType>
void Graphics::TileAnimator< StateType >::handleQueuedEvent ( std::shared_ptr< Events::Event event)
inlineoverridevirtual

HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.

Parameters
[in]eventThe event

Reimplemented from Component.

References Events::ANIMATION_TRIGGER, Component::handleQueuedEvent(), and Graphics::TileAnimator< StateType >::triggerAnimation().

Referenced by Graphics::TileAnimator< StateType >::onNotifyNow(), and Graphics::TileAnimator< StateType >::onUpdate().

template<typename StateType>
virtual void Graphics::TileAnimator< StateType >::log ( el::base::type::ostream_t &  os) const
inlinevirtual

Reimplemented from Component.

References Component::log().

template<typename StateType>
virtual void Graphics::TileAnimator< StateType >::onDestroy ( )
inlineoverridevirtual

Called when the engine is shutting down.

Implements Component.

template<typename StateType>
void Graphics::TileAnimator< StateType >::onNotifyNow ( std::shared_ptr< Events::Event event)
inlineoverridevirtual

When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.

Parameters
[in]eventThe event

Reimplemented from Component.

References Graphics::TileAnimator< StateType >::handleQueuedEvent().

template<typename StateType>
virtual void Graphics::TileAnimator< StateType >::onStart ( )
inlineoverridevirtual

Called when the engine starts and when a new scene is loaded.

Implements Component.

References Graphics::SetUniformEvent::create(), Events::Subject::notify(), and Graphics::Uniform::setData().

template<typename StateType>
virtual bool Graphics::TileAnimator< StateType >::onUpdate ( const double  delta)
inlineoverridevirtual
template<typename StateType>
void Graphics::TileAnimator< StateType >::popFrameBack ( const StateType &  state)
inline

Pops a frame from the back.

Parameters
[in]stateThe state
template<typename StateType>
void Graphics::TileAnimator< StateType >::popFrameFront ( const StateType &  state)
inline

Pops a frame from the front.

Parameters
[in]stateThe state
template<typename StateType>
void Graphics::TileAnimator< StateType >::setStartingState ( const StateType &  state)
inline

Sets the starting state.

Parameters
[in]stateThe state
template<typename StateType>
void Graphics::TileAnimator< StateType >::triggerAnimation ( const StateType &  state)
inline

Triggers animation of state.

Parameters
[in]stateThe state

Referenced by Graphics::TileAnimator< StateType >::handleQueuedEvent().


The documentation for this class was generated from the following file: