CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds) { CCTimer *pTimer = new CCTimer(); pTimer->initWithTarget(pTarget, pfnSelector, fSeconds); pTimer->autorelease(); return pTimer; }
CCTimer* CCTimer::timerWithScriptHandler(int nHandler, ccTime fSeconds) { CCTimer *pTimer = new CCTimer(); pTimer->initWithScriptHandler(nHandler, fSeconds); pTimer->autorelease(); return pTimer; }
CCTimer* CCTimer::timerWithScriptFuncName(const char* pszFuncName, ccTime fSeconds) { CCTimer *pTimer = new CCTimer(); pTimer->initWithScriptFuncName(pszFuncName, fSeconds); pTimer->autorelease(); return pTimer; }
void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused) { CCAssert(pfnSelector, ""); CCAssert(pTarget, ""); tHashSelectorEntry *pElement = NULL; HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); if (! pElement) { pElement = (tHashSelectorEntry *)calloc(sizeof(*pElement), 1); pElement->target = pTarget; if (pTarget) { pTarget->retain(); } HASH_ADD_INT(m_pHashForSelectors, target, pElement); // Is this the 1st element ? Then set the pause level to all the selectors of this target pElement->paused = bPaused; } else { CCAssert(pElement->paused == bPaused, ""); } if (pElement->timers == NULL) { pElement->timers = ccArrayNew(10); } else { for (unsigned int i = 0; i < pElement->timers->num; ++i) { CCTimer *timer = (CCTimer*)pElement->timers->arr[i]; if (pfnSelector == timer->m_pfnSelector) { CCLOG("CCSheduler#scheduleSelector. Selector already scheduled."); timer->m_fInterval = fInterval; return; } } ccArrayEnsureExtraCapacity(pElement->timers, 1); } CCTimer *pTimer = new CCTimer(); pTimer->initWithTarget(pTarget, pfnSelector, fInterval); ccArrayAppendObject(pElement->timers, pTimer); pTimer->release(); }