首页 > 其他 > 详细

让精灵改变方向并前进

时间:2014-11-27 17:38:25      阅读:104      评论:0      收藏:0      [点我收藏+]
//让精灵动起来,并改变方向
void EnemyBase::changeDirection(float dt)  
{  
    auto curr = currPoint();  
    if(curr->getPositionX() > this->getPosition().x )  
    {  
        runAction( Animate::create(AnimationCache::getInstance()->getAnimation("runright"))) ;  
    }else{  
        runAction( Animate::create(AnimationCache::getInstance()->getAnimation("runleft"))  );  
    }  
}
//敌人前进的动画
void EnemyBase::runFllowPoint()  
{  
    auto point = currPoint();  
    setPosition(point->getPosition());  
    point = nextPoint();     
    if( point!= NULL ){  
        runAction(CCSequence::create(MoveTo::create(getRunSpeed(), point->getPosition())  
                                        , CallFuncN::create(CC_CALLBACK_0(EnemyBase::runFllowPoint, this))  
                                        , NULL));  
    }  
}

 

让精灵改变方向并前进

原文:http://www.cnblogs.com/newlist/p/4126526.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!