当前位置: 首页>>代码示例>>C++>>正文


C++ ActionNode::getFirstSpriteFrame方法代码示例

本文整理汇总了C++中ActionNode::getFirstSpriteFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionNode::getFirstSpriteFrame方法的具体用法?C++ ActionNode::getFirstSpriteFrame怎么用?C++ ActionNode::getFirstSpriteFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActionNode的用法示例。


在下文中一共展示了ActionNode::getFirstSpriteFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: performAnimation

void Object::performAnimation(string name, SEL_CallFunc func){
    if (this->getCurrentObjectState() == ObjectStateDead && name.compare("Dead") != 0) {
        return;
    }
    
    CCSpriteBatchNode *currentSpriteBatchNode = m_pobBatchNode;
    CCSpriteBatchNode *newSpriteBatchNode = NULL;

    // Get the action pair by key name
    CCArray *actionPair = (CCArray *)actionsHashes->objectForKey(name);
    // If the action pair does not exist, return early
    if (!actionPair) {
        return;
    }
    newSpriteBatchNode = (CCSpriteBatchNode *)actionPair->objectAtIndex(1);
    ActionNode *actionNode = (ActionNode *)actionPair->objectAtIndex(0);
    
    this->stopActionByTag(ACTION_ANIMATION_TAG);
    
    // If required spriteBatchNode is different from current, replace it
    if (currentSpriteBatchNode != newSpriteBatchNode) {
        this->removeFromParentAndCleanup(false);
        this->setTexture(actionNode->getFirstSpriteFrame()->getTexture());
        this->setTextureRect(actionNode->getFirstSpriteFrame()->getRect());
        newSpriteBatchNode->addChild(this);
    }

    if (func != NULL) {
        CCAssert(dynamic_cast<CCRepeatForever*>(actionNode->getAnimation()) == NULL, "Not able to call function for CCRepeatForever action.");
        
        // Create animation followed by a function call
        CCSequence *seq = CCSequence::createWithTwoActions(actionNode->getAnimation(), CCCallFunc::create(this, func));
        seq->setTag(ACTION_ANIMATION_TAG);
        this->runAction(seq);
    } else {
        // Run the action
        actionNode->getAnimation()->setTag(ACTION_ANIMATION_TAG);
        this->runAction(actionNode->getAnimation());
    }
    
    // Run AI in this action
    {
        if (actionPair->count() > 2) {
            CCArray *AIActions = (CCArray *)actionPair->objectAtIndex(2);
            CCLOG("%s is running AI, total AIAction count: %d", identifier.c_str(), AIActions->count());
            for (int i = 0; i < AIActions->count(); i++) {
                CCAction *action = (CCAction*)AIActions->objectAtIndex(i);
                this->runAction(action);
            }
        }
    }
}
开发者ID:killing333,项目名称:Colors,代码行数:52,代码来源:Object.cpp


注:本文中的ActionNode::getFirstSpriteFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。