MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / update

Method update

Source/Basic/Scheduler.cpp:160–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160bool Scheduler::update(double deltaTime) {
161 // not save _deltaTime on the stack memory
162 _deltaTime = deltaTime * _timeScale;
163 _leftTime += deltaTime;
164
165 double fixedDelta = 1.0 / _fixedFPS;
166 double fixedDeltaTime = fixedDelta * _timeScale;
167 while (_leftTime > fixedDelta) {
168 _fixedUpdateObjects.reserve(_fixedUpdateList.size());
169 for (auto item : _fixedUpdateList) {
170 _fixedUpdateObjects.emplace_back(item->target, item);
171 }
172 for (const auto& fixedUpdateObject : _fixedUpdateObjects) {
173 if (fixedUpdateObject.second->fixedUpdate(fixedDeltaTime)) {
174 unscheduleFixed(fixedUpdateObject.second);
175 }
176 }
177 _fixedUpdateObjects.clear();
178 _leftTime -= fixedDelta;
179 }
180
181 /* update actions */
182 int i = 0, count = s_cast<int>(_actionList->getCount());
183 while (i < count) {
184 auto temp = _actionList->get(i).get();
185 if (temp) {
186 Ref<Action> action(temp->as<Action>());
187 if (!action->isPaused()) {
188 int lastIndex = action->_order;
189 action->_elapsed += s_cast<float>(_deltaTime) * action->_speed;
190 if (action->updateProgress()) {
191 if (action->_order == lastIndex) {
192 Ref<Node> target(action->_target);
193 unschedule(action);
194 target->removeAction(action);
195 target->emit("ActionEnd"_slice, action.get(), target.get());
196 if (action->_looped) {
197 target->runAction(action, true);
198 }
199 }
200 }
201 }
202 } else {
203 _actionList->fastRemoveAt(i);
204 if (i < s_cast<int>(_actionList->getCount())) {
205 const auto& item = _actionList->get(i);
206 if (item) {
207 if (Action* action = item->as<Action>()) {
208 action->_order = i;
209 }
210 }
211 }
212 i--;
213 count--;
214 }
215 i++;
216 }
217

Callers

nothing calls this directly

Calls 14

stopFunction · 0.85
updateProgressMethod · 0.80
runActionMethod · 0.80
fastRemoveAtMethod · 0.80
clearMethod · 0.65
getMethod · 0.65
reserveMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
fixedUpdateMethod · 0.45
getCountMethod · 0.45
isPausedMethod · 0.45

Tested by

no test coverage detected