首页 > 代码库 > 让精灵改变方向并前进

让精灵改变方向并前进

//让精灵动起来,并改变方向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));      }  }

 

让精灵改变方向并前进