void CCDirector::drawScene(void)
{
…...
//tick before glClear: issue #533
if (! m_bPaused) //暂停
{
m_pScheduler->update(m_fDeltaTime); //待会会解释这里的内容
}
@since v2.0
*/
CC_PROPERTY(CCScheduler*, m_pScheduler, Scheduler);
We can use getter to read the variable, and use the setter to change the variable.
@param varType : the type of variable.
@param varName : variable name.
@param funName : "get + funName" is the name of the getter.
"set + funName" is the name of the setter.
@warning : The getter and setter are public virtual functions, you should rewrite them first.
The variables and methods declared after CC_PROPERTY are all public.
If you need protected or private, please declare.
*/
#define CC_PROPERTY(varType, varName, funName)\
protected: varType varName;\
public: virtual varType get##funName(void);\
public: virtual void set##funName(varType var);
void CCScheduler::update(float dt)
// The 'timers' array may change while inside this loop
for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex))
{
elt->currentTimer = (CCTimer*)(elt->timers->arr[elt->timerIndex]);
elt->currentTimerSalvaged = false;
elt->currentTimer->update(dt); //这里又有一个update函数哟
if (elt->currentTimerSalvaged)
{
// The currentTimer told the remove itself. To prevent the timer from
// accidentally deallocating itself before finishing its step, we retained
// it. Now that step is done, it's safe to release it.
elt->currentTimer->release();
}
elt->currentTimer = NULL;
}
{
…..
if (m_bRunForever && !m_bUseDelay)
{//standard timer usage
m_fElapsed += dt;
if (m_fElapsed >= m_fInterval)
{
if (m_pTarget && m_pfnSelector)
{
(m_pTarget->*m_pfnSelector)(m_fElapsed); //第一个出现了
}
…..
if( m_fElapsed >= m_fDelay )
{
if (m_pTarget && m_pfnSelector)
{
(m_pTarget->*m_pfnSelector)(m_fElapsed); //第二个出现了
}
……..
else
{
if (m_fElapsed >= m_fInterval)
{
if (m_pTarget && m_pfnSelector)
{
(m_pTarget->*m_pfnSelector)(m_fElapsed); //第三个出现了
}
……..
}
{
this->schedule(selector, interval, kCCRepeatForever, 0.0f);
}
void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
{
CCAssert( selector, "Argument must be non-nil");
CCAssert( interval >=0, "Argument must be positive");
m_pScheduler->scheduleSelector(selector, this, interval , repeat, delay, !m_bRunning);
}
{
。。。。。
。
CCTimer *pTimer = new CCTimer();
pTimer->initWithTarget(pTarget, pfnSelector, fInterval, repeat, delay); //看这里
ccArrayAppendObject(pElement->timers, pTimer);
pTimer->release();
}
{
m_pTarget = pTarget;
。。
。。
return true;
}
也就是说pTarget是CCNode对象。
版权声明:本文博主原创文章,博客,未经同意不得转载。