Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/animation.h @ 3782

Last change on this file since 3782 was 3782, checked in by bensch, 19 years ago

orxonox/branches/textEngine: added Anim a superclass of Animation, for handling animation-ticking in a List…

File size: 1.7 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16
17/*!
18    \file animation.h
19    A Set of functions to animate some floats inside of an Object
20*/
21
22#ifndef _ANIMATION_H
23#define _ANIMATION_H
24
25
26// FORWARD DEFINITION
27template<class T> class tList;
28
29enum ANIM_FUNCTION {ANIM_LINEAR };
30
31class Anim
32{
33 protected:
34  Anim();
35
36  static tList<Anim>* animatorList;
37};
38
39
40//! A Class to handle some animation for single floated values.
41template<class T> class Animation : public Anim
42{
43 public:
44  Animation();
45  virtual ~Animation();
46
47  void setFuncToAnim(T* object, void (T::*animFunc)(float));
48  void setAnimFunc();
49  void setValue(float value);
50
51  void tick(float time);
52
53 private:
54  void (T::*animFunc)(float);
55 
56  float value;
57  T* object;
58};
59
60
61
62/**
63   \brief standard constructor
64
65*/
66template<class T>
67Animation<T>::Animation () 
68{
69   this->value = 0.0;
70}
71
72
73/**
74   \brief standard deconstructor
75
76*/
77template<class T>
78Animation<T>::~Animation () 
79{
80  // delete what has to be deleted here
81}
82
83
84template<class T>
85void Animation<T>::setFuncToAnim(T* object, void (T::*animFunc)(float))
86{
87  this->object = object;
88  this->animFunc = animFunc;
89}
90
91template<class T>
92void Animation<T>::setValue(float value)
93{
94  this->value = value;
95  (object->*(animFunc))(value);
96}
97
98template<class T>
99void Animation<T>::tick(float time)
100{
101  setValue(value+time/1000);
102  if (value >1)
103    setValue (0);
104}
105
106#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.