MCPcopy Create free account
hub / github.com/axmolengine/axmol / update

Method update

core/base/Scheduler.cpp:63–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void Timer::update(float dt)
64{
65 if (_elapsed == -1)
66 {
67 _elapsed = 0;
68 _timesExecuted = 0;
69 return;
70 }
71
72 // accumulate elapsed time
73 _elapsed += dt;
74
75 // deal with delay
76 if (_useDelay)
77 {
78 if (_elapsed < _delay)
79 {
80 return;
81 }
82 _timesExecuted += 1; // important to increment before call trigger
83 trigger(_delay);
84 _elapsed = _elapsed - _delay;
85 _useDelay = false;
86 // after delay, the rest time should compare with interval
87 if (isExhausted())
88 { // unschedule timer
89 cancel();
90 return;
91 }
92 }
93
94 // if _interval == 0, should trigger once every frame
95 float interval = (_interval > 0) ? _interval : _elapsed;
96 while ((_elapsed >= interval) && !_aborted)
97 {
98 _timesExecuted += 1; // important to increment before call trigger
99 trigger(interval);
100 _elapsed -= interval;
101
102 if (isExhausted())
103 {
104 cancel();
105 break;
106 }
107
108 if (_elapsed <= 0.f)
109 {
110 break;
111 }
112 }
113}
114
115bool Timer::isExhausted() const
116{

Callers 2

scheduleUpdateFunction · 0.45
drawSceneMethod · 0.45

Calls 15

cancelFunction · 0.85
isAbortedMethod · 0.80
isMarkedForDeletionMethod · 0.80
getTimerMethod · 0.80
eraseFunction · 0.50
emptyMethod · 0.45
callbackMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
releaseMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected