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


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

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


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

示例1: initActions

void Object::initActions(){
    StoredDataHandler *storedDataHandler = StoredDataHandler::sharedInstance();
    
    // Store the SpriteIndexNodes related to this object
    spriteIndexNodes = storedDataHandler->getSpriteIndexHashes(identifier, objectType, spriteBatchHandler, Object_Z_Order);
    spriteIndexNodes->retain();
    
    // Get the actions of this object
    CCArray *actions = storedDataHandler->getActionHashes(identifier, objectType);
    actionsHashes = CCDictionary::create();
    actionsHashes->retain();
    
    // Init sprite frame for all action
    {
        for (int i = 0; i < actions->count(); i++) {
            ActionNode *node = (ActionNode *)actions->objectAtIndex(i);
            CCArray *frames = node->spriteIndexes;

            // The assumption is all the sprite frames in a action belong to the same texture
            SpriteIndexNode *spriteIndexNode = this->getSpriteIndexNodeBySpriteIndex(node->getFirstSpriteIndex());
            
            // Create sprite frame objects
            CCArray *spriteFrame = CCArray::create();
            for (int j = 0; j < frames->count(); j++) {
                CCString *spriteIndexStr = (CCString *)frames->objectAtIndex(j);
                int spriteIndex = spriteIndexStr->intValue();
                spriteFrame->addObject(spriteIndexNode->getSpriteFrameByIndex(spriteIndex));
            }
            node->setFirstSpriteFrame((CCSpriteFrame*)spriteFrame->objectAtIndex(0));
            
            // Create animation object
            CCAnimation *animation = CCAnimation::createWithSpriteFrames(spriteFrame, node->delay);
            CCFiniteTimeAction *action = NULL;
            if (node->isRecursive) {
                action = CCRepeatForever::create(CCAnimate::create(animation));
            } else {
                action = CCAnimate::create(animation);
            }
            node->setAnimation(action);
            
            // Get AIActions in this action 
            CCArray *AIActions = storedDataHandler->getAIActionsInAction(identifier, node->name, objectType);
            
            CCArray *actionArray = CCArray::create(node, spriteIndexNode->getSpriteBatchNode(), AIActions, NULL);
            
            // Add (CCAction, CCSpriteBatchNode) into the action hash
            actionsHashes->setObject(actionArray, node->name);
        }
    }

    this->performIdleAnimation();
}
开发者ID:killing333,项目名称:Colors,代码行数:52,代码来源:Object.cpp


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