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


C++ CCAnimation::getFrames方法代码示例

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


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

示例1: animate

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();
}
开发者ID:jjay,项目名称:trooperfall,代码行数:32,代码来源:Trooper.cpp

示例2: animateForever

void Trooper::animateForever(CCObject* animation){
    CCAnimation* anim = (CCAnimation*)animation;
    if (m_current_sprite != NULL && m_animate_action != NULL){
        m_current_sprite->stopAction(m_animate_action);
        m_animate_action = NULL;
    }
    if (m_current_sprite == NULL){
        m_current_sprite = CCSprite::spriteWithSpriteFrame(anim->getFrames()->getObjectAtIndex(0));
    }
    m_animate_action = CCRepeatForever::actionWithAction(CCAnimate::actionWithAnimation(anim));
    m_current_sprite->runAction(m_animate_action);
}
开发者ID:jjay,项目名称:trooperfall,代码行数:12,代码来源:Trooper.cpp

示例3: setDisplayFrameWithAnimationName

void CAImageView::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
{
    CCAssert(animationName, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");

    CCAnimation *a = CCAnimationCache::sharedAnimationCache()->animationByName(animationName);

    CCAssert(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found");

    CCAnimationFrame* frame = (CCAnimationFrame*)a->getFrames()->objectAtIndex(frameIndex);

    CCAssert(frame, "CCSprite#setDisplayFrame. Invalid frame");

    setDisplayFrame(frame->getSpriteFrame());
}
开发者ID:anarki1234,项目名称:9miao,代码行数:14,代码来源:CCSprite.cpp

示例4: setDisplayFrame

// XXX deprecated
void CCSprite::setDisplayFrame(const char *pszAnimationName, int nFrameIndex)
{
    if (! m_pAnimations)
    {
        initAnimationDictionary();
    }

    CCAnimation *pAnimation = m_pAnimations->objectForKey(std::string(pszAnimationName));
    CCSpriteFrame *pFrame = pAnimation->getFrames()->getObjectAtIndex(nFrameIndex);

    assert(pFrame);

    setDisplayFrame(pFrame);
}
开发者ID:valentinvit,项目名称:cocos2d-x,代码行数:15,代码来源:CCSprite.cpp

示例5: setDisplayFrameWithAnimationName

void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
{
    assert(animationName);

    CCAnimation *a = CCAnimationCache::sharedAnimationCache()->animationByName(animationName);

    assert(a);

    CCSpriteFrame *frame = a->getFrames()->getObjectAtIndex(frameIndex);

    assert(frame);

    setDisplayFrame(frame);
}
开发者ID:valentinvit,项目名称:cocos2d-x,代码行数:14,代码来源:CCSprite.cpp

示例6: RemoveFromBattle

void BattleCharacter::RemoveFromBattle()
{
    EventHandler* pHandler = EventHandler::instance();
    AnimationManager* pManger = AnimationManager::instance();
    CCAnimation* pVanishAnimation =pManger->CreateMapCharacterVanishAnimation();
    CCSprite* pVanish = CCSprite::createWithSpriteFrame(dynamic_cast<CCAnimationFrame*>(pVanishAnimation->getFrames()->objectAtIndex(0))->getSpriteFrame());
    pVanish->setPosition(ccp(this->GetMapPositionX(),this->GetMapPositionY()));
    //注册事件
    EventHandler::instance()->OnCharacterRemoveFromBattle(this);
    //移除自身地图精灵
    m_pMapSprites->removeFromParentAndCleanup(true);
    m_pHPBarOff->removeFromParentAndCleanup(true);
    m_pHPBar->removeFromParentAndCleanup(true);
    //加入消除精灵
    m_pMap->addChild(pVanish);
    pVanish->runAction(CCSequence::create(CCAnimate::create(pVanishAnimation),CCCallFuncND::create(pManger,callfuncND_selector(AnimationManager::RemoveAniamationSprite),(void*)pVanish),NULL));
    m_pMap->GetUnits()->removeObject(this);

}
开发者ID:Liang-Shan-Bo,项目名称:SRPG,代码行数:19,代码来源:BattleCharacter.cpp

示例7: SimulationSkill

bool BattleCharacter::SimulationSkill(BattleCharacter* pInvoker,CCArray* pTargets)
{	
    CCArray* pEffectTargets =CCArray::createWithCapacity(pTargets->count());
    pEffectTargets->retain();
    bool bCommandSuc = false;
    for(unsigned int index = 0;index<pTargets->count();index++)
    {
        SkillDataLoader* pData = SkillDataLoader::instance();
        int nID = pInvoker->m_nOnUseID;
        int nType = 0;
        pData->GetSkillValue(DATA_SKILL_TYPE,nID,&nType);
        BattleCharacter* pTarget = (BattleCharacter*)pTargets->objectAtIndex(index);
        //判断是否产生伤害
        bool bDamage = (nType == SKILL_TYPE_DAMAGE)||(nType == SKILL_TYPE_DAMAGE_AND_HEALING);
        bool bHealing = (nType == SKILL_TYPE_HEALING)||(nType == SKILL_TYPE_DAMAGE_AND_HEALING);
        if(bDamage&&(!pInvoker->InSameRace(pTarget)))
        {
            int nDamage = BattleCharacter::GetSkillHPDam(pInvoker,pTarget);	
            pTarget->m_nHP += -nDamage;
            pTarget->m_nHPoffset += -nDamage;
            //pTarget->ShowMapDam(nDamage);
            //pTarget->RefreshHPBar();
            bCommandSuc = true;
            AquireExpFromAttack(pInvoker,pTarget);
            if (!pEffectTargets->containsObject(pTarget))
            {
                pEffectTargets->addObject(pTarget);
            }
        }
        else if(bHealing&&pInvoker->InSameRace(pTarget))
        {
            int nHealing = BattleCharacter::GetSkillHPHeal(pInvoker,pTarget);
            pTarget->m_nHP += nHealing;
            pTarget->m_nHPoffset += nHealing;
            bCommandSuc = true;
            AquireExpFromAttack(pInvoker,pTarget);
            if (!pEffectTargets->containsObject(pTarget))
            {
                pEffectTargets->addObject(pTarget);
            }
        }
    }
    if(bCommandSuc)
    {
        CCArray* pAnimations = AnimationManager::instance()->CreateMapSkillAnimations(pInvoker->m_nOnUseID);
        CCAnimation* pMapSkillAnimation = (CCAnimation*)pAnimations->objectAtIndex(0);
        CCSprite* pMapSkillSprite = CCSprite::createWithSpriteFrame(dynamic_cast<CCAnimationFrame*>(pMapSkillAnimation->getFrames()->objectAtIndex(0))->getSpriteFrame());
        CCSprite* pMapSkillBackgroundSprite = NULL;
        CCAnimation* pMapSkillBackgroundAniation  = NULL;
        if (pAnimations->count()>1)
        {
            pMapSkillBackgroundAniation = (CCAnimation*)pAnimations->lastObject();
            pMapSkillBackgroundSprite = CCSprite::createWithSpriteFrame(dynamic_cast<CCAnimationFrame*>(pMapSkillBackgroundAniation->getFrames()->objectAtIndex(0))->getSpriteFrame());
        }
        if (pMapSkillBackgroundSprite!=NULL)
        {
            pMapSkillBackgroundSprite->setPosition(ccp(pInvoker->m_nCommandX,pInvoker->m_nCommandY));
            CharacterStatus::m_pMap->addChild(pMapSkillBackgroundSprite,MAX_LAYER_ZORDER-1,LAYER_MAPSKILLBACKGROUND_ID);
            pMapSkillBackgroundSprite->runAction(CCRepeatForever::create(CCAnimate::create(pMapSkillBackgroundAniation)));
            pMapSkillSprite->setPosition(ccp(pMapSkillBackgroundSprite->getPositionX(),pMapSkillBackgroundSprite->getPositionY()+GetSpriteTextureHeight(pMapSkillBackgroundSprite)));
        }
        else
        {
            pMapSkillSprite->setPosition(ccp(pInvoker->m_nCommandX,pInvoker->m_nCommandY));
        }
        CharacterStatus::m_pMap->addChild(pMapSkillSprite,MAX_LAYER_ZORDER);
        pMapSkillSprite->runAction(CCSequence::create(CCAnimate::create(pMapSkillAnimation),CCCallFuncND::create(pInvoker,callfuncND_selector(BattleCharacter::MapSkillEffectsCallBack),(void*)pEffectTargets),NULL));


    }
    return bCommandSuc;
}
开发者ID:Liang-Shan-Bo,项目名称:SRPG,代码行数:72,代码来源:BattleCharacter.cpp


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