Changeset 3781 in orxonox.OLD for orxonox/branches/textEngine/src/animation.h
- Timestamp:
- Apr 12, 2005, 1:05:46 AM (19 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/animation.h
r3779 r3781 1 /*! 2 \file proto_class.h 3 \brief Definition of the proto class template, used quickly start work 4 \todo Example: this shows how to use simply add a Marker that here has to be done something. 1 /* 2 orxonox - the future of 3D-vertical-scrollers 5 3 6 The Protoclass exists, to help you quikly getting the run for how to develop in orxonox. 7 It is an example for the CODING-CONVENTION, and a starting-point for every class. 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: ... 8 14 */ 9 15 10 #ifndef _PROTO_CLASS_H11 #define _PROTO_CLASS_H12 16 13 #include "what realy has to be included" 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 14 25 #include "base_object.h" 15 26 16 // FORWARD DEFINITION \\ 17 class someClassWeNeed; 27 enum ANIM_FUNCTION {ANIM_LINEAR }; 28 29 //! A Class to handle some animation for single floated values. 30 template<class T> class Animation : public BaseObject 31 { 32 public: 33 Animation(); 34 virtual ~Animation(); 35 36 void setFuncToAnim(T* object, void (T::*animFunc)(float)); 37 void setAnimFunc(); 38 void setValue(float value); 39 40 void tick(float time); 41 42 private: 43 void (T::*animFunc)(float); 44 45 float value; 46 T* object; 47 }; 18 48 19 49 20 /*class Test;*/ /* forward definition of class Test (without including it here!)*/21 50 22 //! A default class that aids you to start creating a new class23 51 /** 24 here can be some longer description of this class 52 \brief standard constructor 53 25 54 */ 26 class ProtoClass : public BaseObject { 55 template<class T> 56 Animation<T>::Animation () 57 { 58 this->setClassName ("Animation"); 59 this->value = 0.0; 60 } 27 61 28 public:29 ProtoClass();30 virtual ~ProtoClass();31 62 32 bool doNonSense (int nothing); 63 /** 64 \brief standard deconstructor 33 65 34 private: 35 int nonSense; //!< doxygen tag here like this for all the variables - delete this variable if you use this 66 */ 67 template<class T> 68 Animation<T>::~Animation () 69 { 70 // delete what has to be deleted here 71 } 36 72 37 };38 73 39 #endif /* _PROTO_CLASS_H */ 74 template<class T> 75 void Animation<T>::setFuncToAnim(T* object, void (T::*animFunc)(float)) 76 { 77 this->object = object; 78 this->animFunc = animFunc; 79 } 80 81 template<class T> 82 void Animation<T>::setValue(float value) 83 { 84 this->value = value; 85 (object->*(animFunc))(value); 86 } 87 88 template<class T> 89 void Animation<T>::tick(float time) 90 { 91 setValue(value+time/1000); 92 if (value >1) 93 setValue (0); 94 } 95 96 #endif /* _ANIMATION_H */
Note: See TracChangeset
for help on using the changeset viewer.