Changeset 496 for code/branches/FICN/src/orxonox/objects/Tickable.h
- Timestamp:
- Dec 12, 2007, 10:37:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/objects/Tickable.h
r433 r496 1 /*! 2 @file Tickable.h 3 @brief Definition of the Tickable interface. 4 5 The Tickable interface provides a tick(dt) function, that gets called every frame. 6 float dt is the time since the last frame. 7 8 Attention: 9 Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the 10 parent::tick(dt) function explicit in their implementation of tick(dt) because it's a virtual function. 11 */ 12 1 13 #ifndef _Tickable_H__ 2 14 #define _Tickable_H__ 3 15 4 #include <OgreFrameListener.h>5 #include " ../core/IdentifierIncludes.h"16 #include "../core/CoreIncludes.h" 17 #include "OgreFrameListener.h" 6 18 7 19 namespace orxonox 8 20 { 9 class TickFrameListener; 21 class TickFrameListener; // Forward declaration 10 22 23 //! The Tickable interface provides a tick(dt) function, that gets called every frame. 11 24 class Tickable : virtual public OrxonoxClass 12 25 { 13 26 public: 27 /** 28 @brief Gets called every frame. 29 @param dt The time since the last frame 30 */ 14 31 virtual void tick(float dt) = 0; 15 32 16 33 protected: 34 /** 35 @brief Constructor: Registers the object in the Tickable-list 36 */ 17 37 Tickable() { RegisterRootObject(Tickable); } 18 38 }; 19 39 40 //! The TickFrameListener calls the tick(dt) function of all Tickables every frame. 20 41 class TickFrameListener : public Ogre::FrameListener 21 42 { 22 43 private: 44 /** @brief Gets called before a frame gets rendered. */ 23 45 bool frameStarted(const Ogre::FrameEvent &evt) 24 46 { 47 // Iterate through all Tickables and call their tick(dt) function 25 48 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 26 49 it->tick(evt.timeSinceLastFrame);
Note: See TracChangeset
for help on using the changeset viewer.