Angel 3.2
A 2D Game Prototyping Engine
Public Member Functions | List of all members
Interval< T > Class Template Reference

Simplifies lerping Actor properties across a timeframe. More...

#include <Interval.h>

Public Member Functions

 Interval (T start, T end, float duration, bool smooth=false)
 
 Interval ()
 
Step (float dt)
 
float GetCurrent ()
 
bool ShouldStep ()
 

Detailed Description

template<class T>
class Interval< T >

This is a helper template class that manages Actor properties during lerp transitions. The following functions show how they are setup, and the Actor::Update function shows how to update and get the next values.

See Also
Actor::MoveTo
Actor::RotateTo
Actor::ChangeColorTo
Actor::ChangeSizeTo

You can use Intervals for ints, floats, and any class that has defined subtraction and division (by a float) operators that return members of that same class. Our Color, Vector2, and Vector3 classes are all able to be used in Intervals.

Definition at line 51 of file Interval.h.

Constructor & Destructor Documentation

template<class T>
Interval< T >::Interval ( start,
end,
float  duration,
bool  smooth = false 
)
inline

Setting up the interval requires a starting value, a target ending state, and how long it should take to get there.

Parameters
startThe starting value
endThe ending value
durationLength of the transition in seconds
smoothWhether to use a smooth interpolation with ease-in and ease-out instead of a simple linear interpolation.

Definition at line 65 of file Interval.h.

template<class T>
Interval< T >::Interval ( )
inline

The default constructor just sets up an Interval that does nothing. It's here because some compilers want it.

Definition at line 80 of file Interval.h.

Member Function Documentation

template<class T>
T Interval< T >::Step ( float  dt)
inline

The step function processes the appropriate change and shuts the interval down if it's finished.

Parameters
dtHow much time has elapsed since the last Step (so how much the Interval should be incremented)
Returns
The current value of the Interval after the Step has been completed.

Definition at line 94 of file Interval.h.

template<class T>
float Interval< T >::GetCurrent ( )
inline

Get the current value without Stepping the Interval

Returns
The current value

Definition at line 131 of file Interval.h.

template<class T>
bool Interval< T >::ShouldStep ( )
inline

Whether or not the Interval still has changes to process. If this returns false, the Interval is done and you can discard it.

Returns

Definition at line 142 of file Interval.h.


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