资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

cocos2d-xCCScheduler-创新互联

CCNode::CCNode(void){

创新互联建站是一家企业级云计算解决方案提供商,超15年IDC数据中心运营经验。主营GPU显卡服务器,站群服务器,成都机柜租用,海外高防服务器,大带宽服务器,动态拨号VPS,海外云手机,海外云服务器,海外服务器租用托管等。

  m_pScheduler = director->getScheduler();

  m_pScheduler->retain();

}

void CCNode::schedule(SEL_SCHEDULE selector)

{

this->schedule(selector, 0.0f, kCCRepeatForever, 0.0f);

}

void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsignedint 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);

}

void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, unsignedint repeat, float delay, bool bPaused)

{

CCAssert(pfnSelector, "Argument selector must be non-NULL");

CCAssert(pTarget, "Argument target must be non-NULL");

tHashTimerEntry *pElement = NULL;

HASH_FIND_INT(m_pHashForTimers, &pTarget, pElement);

if (! pElement)

  {

    pElement = (tHashTimerEntry *)calloc(sizeof(*pElement), 1);

    pElement->target = pTarget;

if (pTarget)

    {

      pTarget->retain();

    }

HASH_ADD_INT(m_pHashForTimers, 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 (unsignedint i = 0; i < pElement->timers->num; ++i)

    {

CCTimer *timer = (CCTimer*)pElement->timers->arr[i];

if (pfnSelector == timer->getSelector())

      {

CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), fInterval);

        timer->setInterval(fInterval);

return;

      }

    }

ccArrayEnsureExtraCapacity(pElement->timers, 1);

  }

CCTimer *pTimer = newCCTimer();

  pTimer->initWithTarget(pTarget, pfnSelector, fInterval, repeat, delay);

ccArrayAppendObject(pElement->timers, pTimer);

  pTimer->release();

}

bool CCDirector::init(void)

{

// scheduler

m_pScheduler = newCCScheduler();

// action manager

m_pActionManager = newCCActionManager();

m_pScheduler->scheduleUpdateForTarget(m_pActionManager, kCCPrioritySystem, false);

}

// Draw the Scene

voidCCDirector::drawScene(void)

{

//tick before glClear: issue #533

if (! m_bPaused)

  {

m_pScheduler->update(m_fDeltaTime);

  }

}

void CCDisplayLinkDirector::mainLoop(void)

{

if (m_bPurgeDirecotorInNextLoop)

  {

m_bPurgeDirecotorInNextLoop = false;

purgeDirector();

  }

elseif (! m_bInvalid)

  {

drawScene();

// release the objects

CCPoolManager::sharedPoolManager()->pop();

  }

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文标题:cocos2d-xCCScheduler-创新互联
当前链接:http://www.cdkjz.cn/article/dpihcj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220