Package fife :: Package extensions :: Module fife_timer :: Class Timer
[hide private]
[frames] | no frames]

Class Timer

source code

fife.fife.TimeEvent --+
                      |
                     Timer

Timer

This class wraps the fife.TimeEvent class to make it easily usable from Python It allows for a TimeEvent to be executed once or multiple times.

Remember FIFE::TimeManager does NOT delete the timer so make sure you keep a reference to this timer to ensure python doesnt delete the timer prematurely.

Instance Methods [hide private]
 
__init__(self, delay=0, callback=None, repeat=0) source code
 
start(self)
Call this to start the timer.
source code
 
stop(self)
Stops the timer
source code
 
updateEvent(self, delta)
This is called by FIFE::TimeManager when the delay has passed.
source code
 
_setDelay(self, delay)
Sets how many milliseconds to wait before executing the callback.
source code
integer
_getDelay(self)
Returns the number of milliseconds to wait before executing the callback.
source code
 
_setCallback(self, callback) source code
 
_getCallback(self) source code
 
_setRepeat(self, repeat)
Sets how many times the timer should be repeated.
source code
integer
_getRepeat(self, repeat)
Returns the number of times the timer will be executed.
source code
boolean
_getActive(self)
Returns True if the timer is active and False if it is not.
source code
integer
_getNumExecuted(self)
Returns the number of times the timer has been executed
source code
boolean
active(self)
Returns True if the timer is active and False if it is not.
source code
integer
numexecuted(self)
Returns the number of times the timer has been executed
source code
Class Variables [hide private]
  delay = property(_getDelay, _setDelay)
  callback = property(_getCallback, _setCallback)
  repeat = property(_getRepeat, _setRepeat)
Method Details [hide private]

__init__(self, delay=0, callback=None, repeat=0)
(Constructor)

source code 
Parameters:
  • delay - The delay in milliseconds to execute the callback
  • callback - The function to execute when the time delay has passed
  • repeat - The number of times to execute the callback. 1=once, 0=forever

start(self)

source code 

Call this to start the timer.

This registers the timer with the time manager. The time manger then calls the timers updateEvent() function when the delay time has passed.

stop(self)

source code 

Stops the timer

This unregisters the timer from the time manager.

updateEvent(self, delta)

source code 

This is called by FIFE::TimeManager when the delay has passed.

Should not be called directly.

_setDelay(self, delay)

source code 

Sets how many milliseconds to wait before executing the callback.

The timer must not be active to change this value

Parameters:
  • delay (integer) - Number of milliseconds to wait before executing the callback.

_getDelay(self)

source code 

Returns the number of milliseconds to wait before executing the callback.

Returns: integer
Number of milliseconds.

_setRepeat(self, repeat)

source code 

Sets how many times the timer should be repeated.

The timer must not be active to change it's repeat value.

Parameters:
  • repeat (integer) - Number of times to repeat the timer. 0=forever, 1=once.

_getRepeat(self, repeat)

source code 

Returns the number of times the timer will be executed.

Returns: integer
Number of times the timer will be executed.

_getActive(self)

source code 

Returns True if the timer is active and False if it is not.

Returns: boolean
True if timer is active, False if it is not.

_getNumExecuted(self)

source code 

Returns the number of times the timer has been executed

Returns: integer
Number of times the timer has been executed

active(self)

source code 

Returns True if the timer is active and False if it is not.

Returns: boolean
True if timer is active, False if it is not.

numexecuted(self)

source code 

Returns the number of times the timer has been executed

Returns: integer
Number of times the timer has been executed