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


C++ Spawn::setTag方法代码示例

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


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

示例1: setHeroStatus

void HeroFrog::setHeroStatus(FrogStatus heroStatus){
    if (m_heroStatus == heroStatus) {
        return;
    }
    m_heroStatus = heroStatus;
   
    Animation* ani;
    Animate* ac;
    this->stopAllActions();
    ani = AnimationCache::getInstance()->getAnimation(animaName[heroStatus].c_str());
    
    Animation* ani1;
    Animate* ac1;
    if (heroStatus == frogJumpDown) {
        ani1 = AnimationCache::getInstance()->getAnimation(animaName[heroStatus+1].c_str());
    }else if (heroStatus == frogJumpUp&& m_isLongJump){
        std::string aniName = animaName[8].c_str();
        ani = AnimationCache::getInstance()->getAnimation(aniName);
    }
    
    
    
    
    Sequence* seq;
    float y;
    float dis;
    float time;
    SpriteFrame* deadFrame ;
    Spawn* sp;
    
    MoveTo* mvTo;
    Point targetPoint;
    
//    CCLOG("---------设置hero状态-----------");
    switch (heroStatus) {
        case frogStatic:
            GameMainHelper::getInstance()->playSound(JUMPOVER);
            ac= Animate::create(ani) ;
            runAction(RepeatForever::create(ac));
            
            break;
        case frogTakeoff:
            ac= Animate::create(ani) ;
            ani->setDelayPerUnit(0.2);
            
            runAction(RepeatForever::create(ac));
            break;
        case frogJumpUp:
        	if(m_isLongJump)
               GameMainHelper::getInstance()->playSound(JUMPSTART_1);
        	else
        		GameMainHelper::getInstance()->playSound(JUMPSTART_0);
            ani->setDelayPerUnit(0.2); //--------待计算
            ac= Animate::create(ani);
            runAction(RepeatForever::create(ac));
            
            break;
        case frogJumpDown:
            ani->setDelayPerUnit(downAnimSpeed); //--------待计算
            ani1->setDelayPerUnit(0.2);
            ac= Animate::create(ani);
            ac1 = Animate::create(ani1);
            runAction(Sequence::create(ac,Repeat::create(ac1,20), NULL) );
            break;
        case frogFall:
            ani->setDelayPerUnit(downAnimSpeed);
            ac= Animate::create(ani);
            targetPoint = GameMainHelper::getInstance()->getHeroPostPoint();
            time =ani->getDelayPerUnit();
            mvTo = MoveTo::create(downAnimSpeed,targetPoint);
            sp = Spawn::create(ac,mvTo, NULL);
            seq = Sequence::create(sp,CCCallFunc::create(CC_CALLBACK_0(HeroFrog::setHeroStatic, this)) , NULL);
            runAction(seq);
            break;
        case frogDead1:
            GameMainHelper::getInstance()->playSound(HEROOVER);
            deadFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("hero_dead2.png");
            this->setDisplayFrame(deadFrame);
             ac= Animate::create(ani);
            y = MIN(GameMainHelper::getInstance()->getEarthH(),getPositionY());
            dis = getPositionY()-y;
            time = dis/downSpeed;
            targetPoint = Point(getPositionX(),y);
            mvTo = MoveTo::create(time,targetPoint);
            
            sp = Spawn::create(Repeat::create(ac,(int)(time/(0.2*3))),mvTo, NULL);
            sp->setTag(DEAD1TAG);
            seq = Sequence::create(DelayTime::create(0.5), sp,CCCallFunc::create(CC_CALLBACK_0(HeroFrog::stopAnimation, this)), NULL);
     
            runAction(seq);
            break;
        case frogDead2:
            GameMainHelper::getInstance()->playSound(HEROOVER);
            ac= Animate::create(ani) ;
            runAction(RepeatForever::create(ac));
            break;
            
        default:
            ac= Animate::create(ani);
            runAction(RepeatForever::create(ac));
//.........这里部分代码省略.........
开发者ID:haohongxian77,项目名称:parabola-x,代码行数:101,代码来源:HeroFrog.cpp


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