[cocos2dx] schedule

I just describe my case.  Environment: ios, javascript. 

In my case, schedule work flow is listed beblow.

CCDisplayLinkDirector::mainLoop -> CCDirector.drawScene - > CCDirector.m_pScheduler->update(m_fDeltaTime)

so, schedule update is handled in main thread of cocos2dx.


in schedule::Update, object is update according to following step

m_pUpdatesNegList :  priority < 0

m_pUpdates0List      : updates with priority == 0

m_pUpdatesPosList :  updates with priority > 0

m_pHashForTimers :  Iterate over all the custom selectors


the top 3 lists is modified by  scheduleUpdateForTarget, pass a priority n to scheduleUpdateForTarget, then the object is added into 1 of 3 lists according to n.

while m_pHashForTimers is modified in  scheduleSelector. and this is what i use in javascript to init a schedule.

scheduleSelector needs some parameters, but I just want to talk about 3 parameters here.

* selector. this is the handler function for this new shedule.

* target.     the object which selector associates to .

* pause.    the pause flag for all selectors associates to.


* if no tHashTimerEntry is found in m_pHashForTimers, just create one, and set the entry to be paused.

* if found one, "pause" parameter must equals to this entry's pause flag, or init a assert.

* * if found a selector in this entry's timer list, just update the interval parameter for the time which hold the selector.

* * if not, just create a new timer, and setup it according to parameters.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章