Changes between Version 2 and Version 3 of code/doc/Tickable
- Timestamp:
- Oct 8, 2008, 1:19:56 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/Tickable
v2 v3 3 3 == Description == 4 4 5 [wiki:Tickable]is an interface that adds only one, but very important, function to the inheriting classes:5 Tickable is an interface that adds only one, but very important, function to the inheriting classes: 6 6 {{{ 7 7 #!cpp … … 17 17 == How to use tick(dt) == 18 18 19 Every class that wants to do something every tick has to inherit from [wiki:Tickable] or from a class that already inherited from [wiki:Tickable]. Note that tick() is a virtual function. This means: If you want to call the tick(dt) function of your parent, you have to do this manually by writing Parent::tick(dt) into the code of your tick(dt) function. This is a bit unhandy, but it allows you to freely decide whether the tick of your class comes before or after (or between) the tick of the parent class. But this might also cause problems when adding tick(dt) to an old class - several childs might already have implemented their own tick(dt). You have to change them all so they call the tick(dt) of your class too.19 Every class that wants to do something every tick has to inherit from Tickable or from a class that already inherited from Tickable. Note that tick() is a virtual function. This means: If you want to call the tick(dt) function of your parent, you have to do this manually by writing Parent::tick(dt) into the code of your tick(dt) function. This is a bit unhandy, but it allows you to freely decide whether the tick of your class comes before or after (or between) the tick of the parent class. But this might also cause problems when adding tick(dt) to an old class - several childs might already have implemented their own tick(dt). You have to change them all so they call the tick(dt) of your class too. 20 20 21 21 == Example ==