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

Method delay

core/base/SimpleTimer.cpp:66–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66TIMER_ID delay(float delay, vcallback_t callback, bool bNative)
67{
68 if (delay > 0)
69 {
70 yasio::ref_ptr<TimerObject> timerObj(new TimerObject(std::move(callback)));
71 auto timerId = reinterpret_cast<TIMER_ID>(++TimerObject::s_timerId);
72
73 std::string key = fmt::format("STMR#{}", fmt::ptr(timerId));
74 Director::getInstance()->getScheduler()->schedule(
75 [timerObj](float /*dt*/) { // lambda expression hold the reference of timerObj automatically.
76 timerObj->callback_();
77 },
78 STIMER_TARGET(bNative), 0, 0, delay, false, key);
79
80 return timerId;
81 }
82 return nullptr;
83}
84
85void kill(TIMER_ID timerId, bool bNative)
86{

Callers

nothing calls this directly

Calls 4

getInstanceFunction · 0.85
formatFunction · 0.70
ptrFunction · 0.50
scheduleMethod · 0.45

Tested by

no test coverage detected