About Store Forum Documentation Contact



Post Reply 
Start animation
Author Message
DNS Offline
Member

Post: #1
Start animation
How start animation my player if, i press enter.

My code:
Bool Player::update()
{
if(Kb.bp(KB_ENTER)){
cskel.animate(L"../data/anim/walk.anim", Time.time());
}
07-17-2012 09:57 PM
Find all posts by this user Quote this message in a reply
neo22 Offline
Member

Post: #2
RE: Start animation
Hello,

You have to write a custom animate() function and add a motion array, like this :

player.h
Code:
STRUCT (Player, Game::Chr)
  virtual void animate();
  virtual Bool update();

  void playAnimation(Str anim);
protected:
  Memc<Motion> _motions;
};

player.cpp
Code:
Bool Player::update()
{
  if(__super::update())
  {
    REPA(T._motions)if(!T._motions[i].updateAuto(3,3))T._motions.remove(i, false);
    return true;
  }
  return false;
}

void Player::animate()
{
  __super::animate();
  REPA(T._motions)cskel.animate(T._motions[i], false);
}

void Player::playAnimation(Str anim)
{
  T._motions.New().set(T.cskel, anim);
}

enjoy
(This post was last modified: 07-22-2012 06:44 PM by neo22.)
07-22-2012 06:43 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply