update Ticker
This commit is contained in:
parent
86bb0e4239
commit
01ce68accb
|
|
@ -37,11 +37,15 @@ TickerPtr Ticker::Create(Duration interval, int times)
|
||||||
Ticker::Ticker()
|
Ticker::Ticker()
|
||||||
: ticked_times_(0)
|
: ticked_times_(0)
|
||||||
, total_times_(0)
|
, total_times_(0)
|
||||||
|
, is_paused_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ticker::Tick()
|
bool Ticker::Tick()
|
||||||
{
|
{
|
||||||
|
if (is_paused_)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!timer_)
|
if (!timer_)
|
||||||
timer_ = Timer::Create();
|
timer_ = Timer::Create();
|
||||||
|
|
||||||
|
|
@ -55,6 +59,9 @@ bool Ticker::Tick()
|
||||||
|
|
||||||
bool Ticker::Tick(Duration dt)
|
bool Ticker::Tick(Duration dt)
|
||||||
{
|
{
|
||||||
|
if (is_paused_)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (ticked_times_ == total_times_)
|
if (ticked_times_ == total_times_)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ public:
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool is_paused_;
|
||||||
int ticked_times_;
|
int ticked_times_;
|
||||||
int total_times_;
|
int total_times_;
|
||||||
Duration interval_;
|
Duration interval_;
|
||||||
|
|
@ -111,21 +112,17 @@ private:
|
||||||
|
|
||||||
inline void Ticker::Pause()
|
inline void Ticker::Pause()
|
||||||
{
|
{
|
||||||
KGE_ASSERT(timer_);
|
is_paused_ = true;
|
||||||
timer_->Pause();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Ticker::Resume()
|
inline void Ticker::Resume()
|
||||||
{
|
{
|
||||||
KGE_ASSERT(timer_);
|
is_paused_ = false;
|
||||||
timer_->Resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Ticker::IsPausing() const
|
inline bool Ticker::IsPausing() const
|
||||||
{
|
{
|
||||||
if (timer_)
|
return is_paused_;
|
||||||
return timer_->IsPausing();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Ticker::GetTickedTimes() const
|
inline int Ticker::GetTickedTimes() const
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue