您的位置:首页 > 其它

让精灵改变方向并前进

2014-11-27 15:54 288 查看
//让精灵动起来,并改变方向
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));
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: