 |
Gorgon Game Engine
|
Go to the documentation of this file.
77 virtual void Progress(
unsigned timepassed) = 0;
80 virtual void Add(
Base &animation);
132 virtual void Progress(
unsigned timepassed)
override final;
181 virtual void Progress(
unsigned timepassed)
override final;
193 virtual void Reset()
override;
211 virtual void Pause();
325 explicit Base(
bool create=
false) {
327 auto timer =
new Timer;
336 if(this->controller) {
337 this->controller->
Remove(*
this);
350 throw std::runtime_error(
"Animation does not have a controller");
virtual int GetDuration() const =0
Returns the duration of the animation if it is a known apriori.
virtual void SetProgress(unsigned progress)
Sets the progress of the timer to the given value.
Definition: Animation.h:140
Base(ControllerBase &controller)
Sets the controller for this animation to the given controller.
Definition: Animation.h:310
virtual void Resume()
Resumes the controller. This method will not have any effect if the animation is finished.
Definition: Animation.h:214
virtual ~ControllerBase()
Destructor.
Definition: Animation.cpp:54
virtual ~Governor()
Destroys this governor. If it is the active governor, default governor will be activated.
Definition: Animation.cpp:21
bool IsPlaying() const
Returns whether the controller is playing its animations right now.
Definition: Animation.h:245
virtual void SetSpeed(float speed)
Changes the speed of the controller.
Definition: Animation.h:219
bool islooping
Looping state.
Definition: Animation.h:267
Governor * governor
Definition: Animation.h:117
double progress
Floating point progress to avoid precision loss due to speed.
Definition: Animation.h:276
virtual void Reset()=0
Resets the animation to the start.
This class provides event mechanism.
Definition: Event.h:134
contains collection, a vector of references.
Base(bool create=false)
This constructor creates a new controller depending on the create parameter.
Definition: Animation.h:325
virtual unsigned GetProgress() const =0
Returns the current progress of the timer.
bool IsPaused() const
Returns whether the controller is paused.
Definition: Animation.h:237
Controllers are required to progress animations.
Definition: Animation.h:65
Event< Controller > FinishedEvent
Will be fired when the controller reaches the finished state.
Definition: Animation.h:259
Controller(double progress=0.0)
Default constructor.
Definition: Animation.cpp:114
virtual void Remove(Base &animation)
Removes the given animation.
Definition: Animation.cpp:78
bool ispaused
Paused state.
Definition: Animation.h:264
virtual ~Timer()
Definition: Animation.h:129
virtual Base & CreateAnimation(bool create=true) const =0
This function should create an animation and depending on the create parameter, it should create a ti...
unsigned length
Length of the animations controlled by this controller.
Definition: Animation.h:279
virtual void Progress(unsigned timepassed) override final
Progresses this controller by the given time.
Definition: Animation.cpp:118
virtual void Delete(Base &animation)
Deletes the given animation.
Definition: Animation.cpp:90
virtual bool IsControlled() const =0
This method allows clients to determine if the progress is controlled.
virtual unsigned GetProgress() const override final
Returns the current progress of the timer.
Definition: Animation.h:145
virtual void SetLength(unsigned length)
Informs controller about the length of the animations its controlling.
Definition: Animation.h:226
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
virtual void Progress(unsigned timepassed) override final
Progresses this timer by moving the timer timepassed milliseconds forwards.
Definition: Animation.cpp:98
This interface marks a class as animation provider.
Definition: Animation.h:283
virtual float GetSpeed()
Returns the current speed of the controller.
Definition: Animation.h:233
This is the base class for all animations.
Definition: Animation.h:306
virtual void Progress(unsigned timepassed)=0
Progresses this timer by moving the timer timepassed milliseconds forwards.
float speed
Current speed.
Definition: Animation.h:270
This class allows finer control for the animations, allowing loop, stopping at the end,...
Definition: Animation.h:169
void SetProgress(double progress)
Sets the current progress of the controller.
Definition: Animation.h:189
Collection is a container for reference typed objects.
Definition: Collection.h:21
virtual bool IsControlled() const override final
This method allows clients to determine if the progress is controlled.
Definition: Animation.h:154
bool IsFinished() const
Whether the controller is finished either by reaching to the end while the speed is positive or reach...
Definition: Animation.h:241
virtual void Pause()
Pauses the controller, until a Resume or Reset is issued.
Definition: Animation.cpp:212
virtual void Loop()
Starts this controller in looping mode.
Definition: Animation.h:208
This class governs the progress of animations.
Definition: Animation.h:26
unsigned progress
Amount of time passed since the start of the animation.
Definition: Animation.h:160
constexpr Type Animation
Definition: GID.h:187
bool collectable
Whether this controller should be collected by the garbage collector when its task is finished.
Definition: Animation.h:115
virtual bool IsControlled() const override final
This method allows clients to determine if the progress is controlled.
Definition: Animation.h:251
virtual void Animate() const
Animates the animations within this governor.
Definition: Animation.cpp:35
virtual void Reset() override
Resets the controller to start from the beginning.
Definition: Animation.cpp:204
virtual void Activate()
Activates this governor, replacing current one.
Definition: Animation.h:34
virtual ~Base()
Virtual destructor.
Definition: Animation.cpp:216
virtual void DeleteAnimation() const
Deletes this animation.
Definition: Animation.h:379
This class is the most basic controller and does not support any operations.
Definition: Animation.h:126
virtual void Reverse()
Reverses the animation direction by negating the speed.
Definition: Animation.h:222
virtual void Play()
Starts this controller to run once.
Definition: Animation.cpp:172
contains event distribution mechanism
virtual Base & CreateAnimation(ControllerBase &timer) const =0
This function should create a new animation with the given controller.
virtual void Add(Base &animation)
This function attaches the given animation to this controller.
Definition: Animation.cpp:73
void Keep()
Resets the flag that will automatically destroy this controller whenever it has no animations left to...
Definition: Animation.h:104
virtual void Reset() override
Resets the timer, basically starting the animation from the start.
Definition: Animation.h:135
virtual bool HasController() const
Returns whether this animation has a controller.
Definition: Animation.h:344
ControllerBase()
Default constructor.
Definition: Animation.cpp:44
virtual void RemoveController()
Removes the controller of this animation.
Definition: Animation.h:357
virtual ~Controller()
Definition: Animation.h:175
virtual bool Progress(unsigned &leftover)=0
This function should progress the animation.
bool IsLooping() const
Checks whether the controller is in loop mode.
Definition: Animation.h:249
static Governor & Default()
Returns the default governor.
Definition: Animation.h:44
static Governor & Active()
Returns the current governor.
Definition: Animation.h:52
virtual void SetController(ControllerBase &controller)
Sets the controller to the given controller.
Definition: Animation.h:334
virtual void SetGovernor(Governor &governor)
Changes the governor of this controller.
Definition: Animation.cpp:63
virtual Provider & MoveOutProvider()=0
This function moves this animation provider into a new provider.
virtual void SetProgress(unsigned progress)
Sets the current progress of the controller.
Definition: Animation.h:184
Containers::Collection< Base > animations
List of animations this controller holds.
Definition: Animation.h:120
ControllerBase * controller
Controller of this animation.
Definition: Animation.h:388
Base(const Base &base)
Copies the animation.
Definition: Animation.h:315
void AutoDestruct()
Set a flag that will automatically destroy this controller whenever it has no animations left to cont...
Definition: Animation.h:100
bool isfinished
Whether the controller is finished.
Definition: Animation.h:273
virtual ~Provider()
Virtual destructor.
Definition: Animation.h:289
virtual ControllerBase & GetController() const
Returns the controller of this animation.
Definition: Animation.h:347