예제 #1
0
void NDKHelper::ExecuteCallfuncs( float dt )
{
	CCObject *obj;
	CCARRAY_FOREACH(callfuncs, obj) {
		CCCallFuncO *callfunc = (CCCallFuncO*) obj;
		callfunc->execute();
	}
예제 #2
0
void Trooper::animate(const char* animationName, ...){
	va_list params;
	va_start(params, animationName);
	const char* nextName = animationName;
	if (m_current_sprite != NULL && m_animate_action != NULL){
		m_current_sprite->stopAction(m_animate_action);
		m_animate_action = NULL;
	}
	CCArray* animations = CCArray::array();

	while (nextName){
		CCAnimation* anim = TFAnimationCache::sharedAnimationCache()->animationByName(nextName);
		if (m_current_sprite == NULL){
			m_current_sprite = CCSprite::spriteWithSpriteFrame(anim->getFrames()->getObjectAtIndex(0));
			this->addChild(m_current_sprite);
		}
		CCCallFuncO* notifyAction = CCCallFuncO::actionWithTarget(this, callfuncO_selector(Trooper::onAnimationStart), new CCString(nextName));
		animations->addObject(notifyAction);
		nextName = va_arg(params, const char*);
		if (nextName == NULL){
			CCCallFuncO* animAction = CCCallFuncO::actionWithTarget(this, callfuncO_selector(Trooper::animateForever), anim);
			animations->addObject(animAction);
			animAction->retain();
		} else {
			animations->addObject(CCAnimate::actionWithAnimation(anim));
		}
		notifyAction->retain();
	}
	m_current_sprite->runAction(CCSequence::actionsWithArray(animations));
	va_end(params);
	animations->retain();
}
예제 #3
0
 CCCallFuncO * CCCallFuncO::actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject)
 {
     CCCallFuncO *pRet = new CCCallFuncO();
     if(pRet->initWithTarget(pSelectorTarget, selector, pObject))
     {
         pRet->autorelease();
         return pRet;
     }
     CC_SAFE_DELETE(pRet);
     return NULL;
 }
CCCallFuncO* CCCallFuncO::actionWithScriptFuncName(const char *pszFuncName) {
	CCCallFuncO *pRet = new CCCallFuncO();

	if (pRet && pRet->initWithScriptFuncName(pszFuncName)) {
		pRet->autorelease();
		return pRet;
	}

	CC_SAFE_DELETE(pRet);
	return NULL;
}
예제 #5
0
CCCallFuncO* CCCallFuncO::create(ccScriptFunction func, CCObject* pObject) {
    CCCallFuncO *pRet = new CCCallFuncO();
    if (pRet && pRet->initWithScriptTarget(func, pObject)) {
        CC_SAFE_AUTORELEASE(pRet);
        return pRet;
    }
    
    CC_SAFE_DELETE(pRet);
    return NULL;
    return pRet;
}
예제 #6
0
void CCRichLabelTTF::onLinkMenuItemClicked(CCObject* sender) {
	CCMenuItemColor* item = (CCMenuItemColor*)sender;
	CCCallFunc* func = (CCCallFunc*)item->getUserData();
    if(func){
        CCCallFuncO *funcO = dynamic_cast<CCCallFuncO*>(func);
        if(funcO){
            funcO->setObject(CCInteger::create(item->getTag() - START_TAG_LINK_ITEM));
        }
		func->execute();
    }
}
예제 #7
0
CCCallFuncO * CCCallFuncO::create(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject)
{
    CCCallFuncO *pRet = new CCCallFuncO();

    if (pRet && pRet->initWithTarget(pSelectorTarget, selector, pObject)) {
        CC_SAFE_AUTORELEASE(pRet);
        return pRet;
    }

    CC_SAFE_DELETE(pRet);
    return NULL;
}
CCCallFuncO* CCCallFuncO::create ( CCObject* pSelectorTarget, SEL_CallFuncO pSelector, CCObject* pObject )
{
    CCCallFuncO*  pRet = new CCCallFuncO ( );

    if ( pRet && pRet->initWithTarget ( pSelectorTarget, pSelector, pObject ) )
    {
        pRet->autorelease ( );
    }
	else
	{
		CC_SAFE_DELETE ( pRet );
	}
    
	return pRet;
}
예제 #9
0
 CCObject * CCCallFuncO::copyWithZone(CCZone* zone)
 {
     CCZone* pNewZone = NULL;
     CCCallFuncO* pRet = NULL;
     if(zone && zone->m_pCopyObject) //in case of being called at sub class
         pRet = (CCCallFuncO*)(zone->m_pCopyObject);
     else
     {
         pRet = new CCCallFuncO();
         zone = pNewZone = new CCZone(pRet);
     }
     CCCallFunc::copyWithZone(zone);
     pRet->initWithTarget(m_pSelectorTarget, m_pCallFuncO, m_pObject);
     CC_SAFE_DELETE(pNewZone);
     return pRet;
 }
CCObject* CCCallFuncO::copyWithZone ( CCZone* pZone )
{
    CCZone*   pNewZone = KD_NULL;
    CCCallFuncO*  pRet = KD_NULL;

    if ( pZone && pZone->m_pCopyObject ) 
	{
        pRet = (CCCallFuncO*) pZone->m_pCopyObject;
	}
    else
    {
        pRet = new CCCallFuncO ( );
        pZone = pNewZone = new CCZone ( pRet );
    }

    CCCallFunc::copyWithZone ( pZone );
    
	pRet->initWithTarget ( m_pSelectorTarget, m_pCallFuncO, m_pObject );
    
	CC_SAFE_DELETE ( pNewZone );
    
	return pRet;
}