本文整理汇总了C++中CCTimer::initWithTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTimer::initWithTarget方法的具体用法?C++ CCTimer::initWithTarget怎么用?C++ CCTimer::initWithTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTimer
的用法示例。
在下文中一共展示了CCTimer::initWithTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timerWithTarget
CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds)
{
CCTimer *pTimer = new CCTimer();
pTimer->initWithTarget(pTarget, pfnSelector, fSeconds);
pTimer->autorelease();
return pTimer;
}
示例2: scheduleSelector
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();
}