![]() |
Gorgon Game Engine
|
This class allows finer control for the animations, allowing loop, stopping at the end, events, speed and direction control. More...
Public Member Functions | |
Controller (double progress=0.0) | |
Default constructor. More... | |
virtual | ~Controller () |
![]() | |
ControllerBase () | |
Default constructor. More... | |
ControllerBase (Governor &governor) | |
virtual | ~ControllerBase () |
Destructor. More... | |
virtual void | Add (Base &animation) |
This function attaches the given animation to this controller. More... | |
void | AutoDestruct () |
Set a flag that will automatically destroy this controller whenever it has no animations left to control. More... | |
virtual void | Delete (Base &animation) |
Deletes the given animation. More... | |
virtual unsigned | GetProgress () const =0 |
Returns the current progress of the timer. More... | |
void | Keep () |
Resets the flag that will automatically destroy this controller whenever it has no animations left to control. More... | |
virtual void | Remove (Base &animation) |
Removes the given animation. More... | |
virtual void | SetGovernor (Governor &governor) |
Changes the governor of this controller. More... | |
Protected Attributes | |
bool | isfinished |
Whether the controller is finished. More... | |
bool | islooping |
Looping state. More... | |
bool | ispaused |
Paused state. More... | |
unsigned | length |
Length of the animations controlled by this controller. More... | |
double | progress |
Floating point progress to avoid precision loss due to speed. More... | |
float | speed |
Current speed. More... | |
![]() | |
Containers::Collection< Base > | animations |
List of animations this controller holds. More... | |
bool | collectable |
Whether this controller should be collected by the garbage collector when its task is finished. More... | |
Governor * | governor |
Progress modification functions | |
virtual void | Progress (unsigned timepassed) override final |
Progresses this controller by the given time. More... | |
virtual void | SetProgress (unsigned progress) |
Sets the current progress of the controller. More... | |
void | SetProgress (double progress) |
Sets the current progress of the controller. More... | |
virtual void | Reset () override |
Resets the controller to start from the beginning. More... | |
Progress control functions | |
virtual void | Play () |
Starts this controller to run once. More... | |
virtual void | Loop () |
Starts this controller in looping mode. More... | |
virtual void | Pause () |
Pauses the controller, until a Resume or Reset is issued. More... | |
virtual void | Resume () |
Resumes the controller. This method will not have any effect if the animation is finished. More... | |
virtual void | SetSpeed (float speed) |
Changes the speed of the controller. More... | |
virtual void | Reverse () |
Reverses the animation direction by negating the speed. More... | |
virtual void | SetLength (unsigned length) |
Informs controller about the length of the animations its controlling. More... | |
Information functions | |
virtual float | GetSpeed () |
Returns the current speed of the controller. More... | |
bool | IsPaused () const |
Returns whether the controller is paused. More... | |
bool | IsFinished () const |
Whether the controller is finished either by reaching to the end while the speed is positive or reaching to 0 while the speed is negative. More... | |
bool | IsPlaying () const |
Returns whether the controller is playing its animations right now. More... | |
bool | IsLooping () const |
Checks whether the controller is in loop mode. More... | |
virtual bool | IsControlled () const override final |
This method allows clients to determine if the progress is controlled. More... | |
Events | |
Event< Controller > | FinishedEvent |
Will be fired when the controller reaches the finished state. More... | |
This class allows finer control for the animations, allowing loop, stopping at the end, events, speed and direction control.
Use SetLength to control the length of the animation. Otherwise, if the first controlled animation exists, its length is used. Best used with a single animation or animations that have the same duration.
Controller | ( | double | progress = 0.0 | ) |
Default constructor.
References Controller::progress, and Controller::SetProgress().
|
virtual |
|
virtual |
Returns the current speed of the controller.
References Controller::speed.
|
finaloverridevirtual |
This method allows clients to determine if the progress is controlled.
If the progress is not controlled, there is no way to force the animation to stop. Therefore, animations with looping capabilities should wrap around to start over. However, if the timer is a controller then the best strategy will be to stop at the end, and return the leftover time. This way, controller can decide what to do next.
Implements ControllerBase.
bool IsFinished | ( | ) | const |
Whether the controller is finished either by reaching to the end while the speed is positive or reaching to 0 while the speed is negative.
References Controller::isfinished.
bool IsLooping | ( | ) | const |
Checks whether the controller is in loop mode.
It also checks the length if the speed is negative and makes sure that the controller can actually loop
References Controller::islooping, Controller::length, and Controller::speed.
bool IsPaused | ( | ) | const |
Returns whether the controller is paused.
Does not check if the speed is 0 or not, setting speed to 0 will effectively pause the animation without changing paused status.
References Controller::ispaused.
bool IsPlaying | ( | ) | const |
Returns whether the controller is playing its animations right now.
This method does not take speed being 0 into account.
References Controller::isfinished, and Controller::ispaused.
|
virtual |
Starts this controller in looping mode.
Looping will not work when the length is 0 and the speed is set to a negative value (animation is running in reverse). If the animation is paused, this function works like Resume except that this function sets controller to looping mode
References Controller::islooping, and Controller::Play().
|
virtual |
Pauses the controller, until a Resume or Reset is issued.
References Controller::ispaused.
|
virtual |
Starts this controller to run once.
If the controller is marked as finished, this method will set the progress to 0 or length depending on the direction of the controller. If length is 0 and the speed is negative this method will not start playing finished controller. If the animation is paused, this function works like Resume except that this function sets controller to run once mode.
References ControllerBase::animations, Controller::isfinished, Controller::islooping, Controller::ispaused, Controller::length, Controller::progress, and Controller::speed.
|
finaloverridevirtual |
Progresses this controller by the given time.
Implements ControllerBase.
References ControllerBase::animations, Controller::FinishedEvent, Controller::isfinished, Controller::islooping, Controller::ispaused, Controller::length, Controller::progress, and Controller::speed.
|
overridevirtual |
Resets the controller to start from the beginning.
Also resets finished and paused status and modifies the speed to be 1.
Implements ControllerBase.
References Controller::isfinished, Controller::ispaused, Controller::progress, and Controller::speed.
|
virtual |
Resumes the controller. This method will not have any effect if the animation is finished.
References Controller::ispaused.
|
virtual |
Reverses the animation direction by negating the speed.
References Controller::speed.
|
virtual |
Informs controller about the length of the animations its controlling.
This allows Controller to seek to the end of the animation
References Controller::length.
void SetProgress | ( | double | progress | ) |
Sets the current progress of the controller.
If the progress is a negative value, it will be subtracted from the animation length. If the animation length is 0, then the controller will immediately stop and sets the progress to 0.
References Controller::progress.
|
virtual |
Sets the current progress of the controller.
References Controller::progress.
|
virtual |
Changes the speed of the controller.
Speed can be negative to run animations backwards. Setting speed 0 effectively pauses the controller, however, when the speed is 0 controller will not report that its paused.
References Controller::speed.
Event<Controller> FinishedEvent |
Will be fired when the controller reaches the finished state.
controller is finished either by reaching to the end while the speed is positive or reaching to 0 while the speed is negative
|
protected |
Whether the controller is finished.
|
protected |
Looping state.
|
protected |
Paused state.
|
protected |
Length of the animations controlled by this controller.
|
protected |
Floating point progress to avoid precision loss due to speed.
|
protected |
Current speed.