Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3783 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Apr 12, 2005, 4:54:45 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: more functionality to animation-class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/textEngine/src/animation.h

    r3782 r3783  
    2727template<class T> class tList;
    2828
    29 enum ANIM_FUNCTION {ANIM_LINEAR };
     29enum ANIM_FUNCTION {ANIM_LINEAR, ANIM_SINE };
     30enum ANIM_INFINITY {ANIM_INF_CONSTANT, ANIM_INF_LINEAR, ANIM_INF_PINGPONG, ANIM_INF_REWIND};//, ANIM_DELETE}
    3031
    3132class Anim
     
    3536
    3637  static tList<Anim>* animatorList;
     38
     39  virtual void tick(float time) = 0;
    3740};
    3841
     
    4548  virtual ~Animation();
    4649
    47   void setFuncToAnim(T* object, void (T::*animFunc)(float));
    48   void setAnimFunc();
     50  void setFuncToAnim(T* object, void (T::*funcToAnim)(float));
     51  void setAnimFunc(ANIM_FUNCTION animFunc);
    4952  void setValue(float value);
    5053
    51   void tick(float time);
     54  virtual void tick(float time);
    5255
    5356 private:
    54   void (T::*animFunc)(float);
    55  
     57  void (T::*funcToAnim)(float);
     58  ANIM_FUNCTION animFunc;
    5659  float value;
    5760  T* object;
     
    8386
    8487template<class T>
    85 void Animation<T>::setFuncToAnim(T* object, void (T::*animFunc)(float))
     88void Animation<T>::setFuncToAnim(T* object, void (T::*funcToAnim)(float))
    8689{
    8790  this->object = object;
    88   this->animFunc = animFunc;
     91  this->funcToAnim = funcToAnim;
    8992}
    9093
     
    9396{
    9497  this->value = value;
    95   (object->*(animFunc))(value);
     98  (object->*(funcToAnim))(value);
    9699}
    97100
     
    99102void Animation<T>::tick(float time)
    100103{
    101   setValue(value+time/1000);
    102   if (value >1)
    103     setValue (0);
     104  setValue(value - time/1000);
     105  if (value < 0)
     106    setValue (1.0);
    104107}
    105108
Note: See TracChangeset for help on using the changeset viewer.