HatchitGame
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Hatchit::Game::TweenComponent Class Reference

Defines the base for tween-based components. More...

#include <ht_tween_component.h>

Inheritance diagram for Hatchit::Game::TweenComponent:
Hatchit::Game::Component Hatchit::Game::TweenPosition Hatchit::Game::TweenRotation Hatchit::Game::TweenScale

Public Types

typedef float(* TweenFunction) (float start, float end, float time, float duration)
 The type for tween function pointers. More...
 

Public Member Functions

 TweenComponent ()
 Creates a new tween component.
 
virtual ~TweenComponent ()
 Destroys this tween component.
 
virtual Core::JSON VSerialize (void) override
 
virtual bool VDeserialize (const Core::JSON &jsonObject) override
 
float GetDuration () const
 Gets the duration of the tween.
 
TweenMethod GetMethod () const
 Gets the tween method.
 
TweenPlayMode GetPlayMode () const
 Gets the tween play mode.
 
bool IsPlaying () const
 Checks to see if this tween is playing.
 
bool Play ()
 Plays the tween. More...
 
bool Play (float duration)
 Plays the tween. More...
 
bool Play (float duration, TweenMethod method)
 Plays the tween. More...
 
bool Play (float duration, TweenMethod method, TweenPlayMode mode)
 Plays the tween. More...
 
void SetDuration (float duration)
 Sets the tween's duration. More...
 
void SetMethod (TweenMethod method)
 Sets the tween method. More...
 
void SetPlayMode (TweenPlayMode mode)
 Sets the play mode. More...
 
void Stop ()
 Stops the tween.
 
void VOnInit () override
 Called when the GameObject is created to initialize all values.
 
virtual void VOnUpdate () override
 Called once per frame while the GameObject is enabled. More...
 
void VOnDestroy () override
 Called when the GameObject is destroyed/deleted. More...
 
ComponentVClone (void) const override
 Creates a copy of this Component.
 
virtual Core::Guid VGetComponentId (void) const override
 Retrieves the id associated with this class of Component. More...
 
- Public Member Functions inherited from Hatchit::Game::Component
 Component (const Component &rhs)=default
 
 Component (Component &&rhs)=default
 
Componentoperator= (const Component &rhs)=default
 
Componentoperator= (Component &&rhs)=default
 
GameObjectGetOwner (void)
 Getter which returns the GameObject to which this Component is attached. More...
 
bool GetEnabled (void)
 Getter that returns that value of m_enabled. More...
 
void SetEnabled (bool value)
 Setter that sets the value of m_enabled. More...
 
void SetOwner (GameObject *owner)
 Setter that sets which GameObject this Component is attached to. More...
 

Protected Member Functions

bool AreValuesCompatible () const
 Checks to see if the start and end values are compatible.
 
void VOnEnabled () override
 Called when the Component is enabled. More...
 
void VOnDisabled () override
 Called when the Component is disabled. More...
 

Static Protected Member Functions

static void CreateTweenFunctions ()
 Creates the global list of tween functions.
 

Protected Attributes

TweenValue m_targetValue
 
TweenValue m_startValue
 
TweenValue m_endValue
 
TweenFunction m_tweenFunction
 
TweenMethod m_tweenMethod
 
TweenPlayMode m_tweenPlayMode
 
float m_startTime
 
float m_duration
 
bool m_isPlaying
 
- Protected Attributes inherited from Hatchit::Game::Component
bool m_enabled {true}
 bool indicating if this Component is enabled. More...
 
GameObjectm_owner
 The GameObject to which this Component is attached. More...
 

Static Protected Attributes

static std::vector< TweenFunctions_tweenFunctions
 

Additional Inherited Members

- Static Public Member Functions inherited from Hatchit::Game::Component
template<typename T >
static Core::Guid GetComponentId (void)
 Returns the unique id associated with a Component of type T. More...
 

Detailed Description

Defines the base for tween-based components.

Member Typedef Documentation

typedef float(* Hatchit::Game::TweenComponent::TweenFunction) (float start, float end, float time, float duration)

The type for tween function pointers.

Parameters
startThe start value.
endThe end value.
timeThe current time in the tween.
durationThe duration of the tween.
Returns
The resulting tween value.

Member Function Documentation

bool Hatchit::Game::TweenComponent::Play ( )

Plays the tween.

Returns
True if the tween has begun, false if there was an error.
bool Hatchit::Game::TweenComponent::Play ( float  duration)

Plays the tween.

Parameters
durationThe duration of the tween.
Returns
True if the tween has begun, false if there was an error.
bool Hatchit::Game::TweenComponent::Play ( float  duration,
TweenMethod  method 
)

Plays the tween.

Parameters
durationThe duration of the tween.
methodThe tween method.
Returns
True if the tween has begun, false if there was an error.
bool Hatchit::Game::TweenComponent::Play ( float  duration,
TweenMethod  method,
TweenPlayMode  mode 
)

Plays the tween.

Parameters
durationThe duration of the tween.
methodThe tween method.
modeThe play mode.
Returns
True if the tween has begun, false if there was an error.
void Hatchit::Game::TweenComponent::SetDuration ( float  duration)

Sets the tween's duration.

Parameters
durationThe new duration.
void Hatchit::Game::TweenComponent::SetMethod ( TweenMethod  method)

Sets the tween method.

Parameters
methodThe new method.
void Hatchit::Game::TweenComponent::SetPlayMode ( TweenPlayMode  mode)

Sets the play mode.

Parameters
methodThe new play mode.
Core::Guid Hatchit::Game::TweenComponent::VGetComponentId ( void  ) const
overridevirtual

Retrieves the id associated with this class of Component.

Returns
The Core::Guid associated with this Component type.
See also
Component(), GameObject()

Implements Hatchit::Game::Component.

Reimplemented in Hatchit::Game::TweenScale, Hatchit::Game::TweenPosition, and Hatchit::Game::TweenRotation.

void Hatchit::Game::TweenComponent::VOnDestroy ( void  )
overridevirtual

Called when the GameObject is destroyed/deleted.

Objects are always disabled before destroyed. When a scene is destroyed, all gameobjects are disabled before any are destroyed.

Implements Hatchit::Game::Component.

void Hatchit::Game::TweenComponent::VOnDisabled ( void  )
overrideprotectedvirtual

Called when the Component is disabled.

Components are always disabled before destroyed. When a scene is destroyed, all Components are disabled before any are destroyed.

Implements Hatchit::Game::Component.

void Hatchit::Game::TweenComponent::VOnEnabled ( void  )
overrideprotectedvirtual

Called when the Component is enabled.

This happens when a scene has finished loading, or immediately after creation if the scene is already loaded.

Implements Hatchit::Game::Component.

void Hatchit::Game::TweenComponent::VOnUpdate ( void  )
overridevirtual

Called once per frame while the GameObject is enabled.

Updates all components first, then all child gameobjects.

Implements Hatchit::Game::Component.

Reimplemented in Hatchit::Game::TweenScale, Hatchit::Game::TweenPosition, and Hatchit::Game::TweenRotation.


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