2018-05-08 20:03:29 +08:00
|
|
|
#include "..\e2daction.h"
|
|
|
|
|
|
|
|
|
|
e2d::Delay::Delay(double duration)
|
2018-05-10 18:18:02 +08:00
|
|
|
: _delta(0)
|
|
|
|
|
, _delay(max(duration, 0))
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e2d::Delay * e2d::Delay::clone() const
|
|
|
|
|
{
|
2018-05-24 22:06:14 +08:00
|
|
|
return Create<Delay>(_delay);
|
2018-05-08 20:03:29 +08:00
|
|
|
}
|
|
|
|
|
|
2018-05-14 00:36:01 +08:00
|
|
|
e2d::Delay * e2d::Delay::reverse() const
|
|
|
|
|
{
|
2018-05-24 22:06:14 +08:00
|
|
|
return Create<Delay>(_delay);
|
2018-05-14 00:36:01 +08:00
|
|
|
}
|
|
|
|
|
|
2018-05-10 18:18:02 +08:00
|
|
|
void e2d::Delay::reset()
|
|
|
|
|
{
|
|
|
|
|
Action::reset();
|
|
|
|
|
_delta = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 20:03:29 +08:00
|
|
|
void e2d::Delay::_init()
|
|
|
|
|
{
|
|
|
|
|
Action::_init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::Delay::_update()
|
|
|
|
|
{
|
|
|
|
|
Action::_update();
|
2018-05-10 14:03:54 +08:00
|
|
|
|
2018-05-10 18:18:02 +08:00
|
|
|
_delta = Time::getTotalTime() - _last;
|
|
|
|
|
|
|
|
|
|
if (_delta >= _delay)
|
2018-05-08 20:03:29 +08:00
|
|
|
{
|
|
|
|
|
this->stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-10 18:18:02 +08:00
|
|
|
|
|
|
|
|
void e2d::Delay::_resetTime()
|
|
|
|
|
{
|
|
|
|
|
Action::_resetTime();
|
|
|
|
|
_last = Time::getTotalTime() - _delta;
|
|
|
|
|
}
|