Platform Data Engine 0.0.1
A data-driven game engine for platformers
PlatformDataEngine::AnimationController Class Reference

A component that manages playing animations on a gameObject. Precondition: the game object must have a sprite renderer component. More...

#include <AnimationController.h>

Inheritance diagram for PlatformDataEngine::AnimationController:
PlatformDataEngine::Component PlatformDataEngine::Networkable

Classes

struct  Animation
 Represents an animation (a collection of frames) More...
 
struct  AnimationFrame
 Represents a frame in an animation More...
 

Public Types

enum  FlipFlags { NONE , HORIZONTAL , VERTICAL }
 Enum for flipping a sprite
 

Public Member Functions

void init ()
 Called once on startup More...
 
void update (const float &dt, const float &elapsedTime)
 Called every update cycle More...
 
void draw (sf::RenderTarget &target, sf::RenderStates states) const
 Called every draw cycle More...
 
void copy (std::shared_ptr< Component > otherCompPtr)
 Essentially a copy constructor except the generic shared pointer must be converted to the derived type using std::dynamic_pointer_cast More...
 
void networkSerialize (PDEPacket &output)
 Use this function to serialize any members you want replicated this is handy for animation components that should copy their state to all client instances More...
 
void networkDeserialize (PDEPacket &input)
 Use this function to deserialize data coming from the server for this specific client More...
 
void loadDefinition (nlohmann::json object)
 Called when game object definitions are loaded More...
 
void setFlipFlag (AnimationController::FlipFlags flip)
 Sets the flip flags for this animation controller More...
 
void setAnimation (const std::string animName, float speed=1.0f, bool loop=true)
 
- Public Member Functions inherited from PlatformDataEngine::Component
virtual void copy (std::shared_ptr< Component > otherCompPtr)
 Essentially a copy constructor except the generic shared pointer must be converted to the derived type using std::dynamic_pointer_cast More...
 
void registerHierarchy (GameObject *parent)
 
virtual void init ()
 Called once on startup More...
 
virtual void update (const float &dt, const float &elapsedTime)
 Called every update cycle More...
 
virtual void draw (sf::RenderTarget &target, sf::RenderStates states) const
 Called every draw cycle More...
 
virtual void networkSerializeInit (PDEPacket &output)
 Called when sending data for the first time More...
 
virtual void networkDeserializeInit (PDEPacket &input)
 Called when recieving data for the first time More...
 
virtual void networkSerialize (PDEPacket &output)
 Use this function to serialize any members you want replicated this is handy for animation components that should copy their state to all client instances More...
 
virtual void networkDeserialize (PDEPacket &input)
 Use this function to deserialize data coming from the server for this specific client More...
 
virtual void loadDefinition (nlohmann::json object)
 Called when game object definitions are loaded More...
 
std::string getType () const
 
nlohmann::json getProps () const
 
void setType (const std::string &type)
 
void setProps (nlohmann::json &props)
 
void setIsDefinition (bool isDef)
 
virtual void networkSerializeInit (PDEPacket &output)=0
 Called when an object is sent to the clients for the first time More...
 
virtual void networkDeserializeInit (PDEPacket &input)=0
 Called when an object is recieved on a client for the first time More...
 
virtual void networkSerialize (PDEPacket &output)=0
 Called every time an object is sent to a client More...
 
virtual void networkDeserialize (PDEPacket &input)=0
 Called every time an object is recieved from a client More...
 

Additional Inherited Members

- Protected Attributes inherited from PlatformDataEngine::Component
std::map< std::string, nlohmann::json > m_properties
 
GameObjectm_parent
 
bool m_isDefinition
 
nlohmann::json m_all_props
 
std::string m_type
 

Detailed Description

A component that manages playing animations on a gameObject. Precondition: the game object must have a sprite renderer component.

Member Function Documentation

◆ copy()

void AnimationController::copy ( std::shared_ptr< Component otherCompPtr)
virtual

Essentially a copy constructor except the generic shared pointer must be converted to the derived type using std::dynamic_pointer_cast

Parameters
otherCompPtr

Reimplemented from PlatformDataEngine::Component.

◆ draw()

void AnimationController::draw ( sf::RenderTarget &  target,
sf::RenderStates  states 
) const
virtual

Called every draw cycle

Parameters
target
states

Reimplemented from PlatformDataEngine::Component.

◆ init()

void AnimationController::init ( )
virtual

Called once on startup

Reimplemented from PlatformDataEngine::Component.

◆ loadDefinition()

void AnimationController::loadDefinition ( nlohmann::json  object)
virtual

Called when game object definitions are loaded

Parameters
object

Reimplemented from PlatformDataEngine::Component.

◆ networkDeserialize()

void AnimationController::networkDeserialize ( PDEPacket input)
virtual

Use this function to deserialize data coming from the server for this specific client

Parameters
input

Reimplemented from PlatformDataEngine::Component.

◆ networkSerialize()

void AnimationController::networkSerialize ( PDEPacket output)
virtual

Use this function to serialize any members you want replicated this is handy for animation components that should copy their state to all client instances

Parameters
output

Reimplemented from PlatformDataEngine::Component.

◆ setFlipFlag()

void PlatformDataEngine::AnimationController::setFlipFlag ( AnimationController::FlipFlags  flip)
inline

Sets the flip flags for this animation controller

Parameters
flipthe new flip flag

◆ update()

void AnimationController::update ( const float &  dt,
const float &  elapsedTime 
)
virtual

Called every update cycle

Parameters
dtdelta time
elapsedTimeelapsed time

Reimplemented from PlatformDataEngine::Component.


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