times something. when it is done it is equal to 1, else equal to 0.
Useage:
v = VirtTimer(5.)
if v:
dosomething()
v.Update(elapsed_time) OR with a callback.
v = VirtTimer(5., dosomething)
v.Update(elapsed_time)
Call Update on each game tick. Passing in elapsed time in seconds
allows you to have timers running on different time. So pausing,
and things like bullet time are easy.
Also has some other features.
You can be notified on the "edge" of time. That is when a timer
is just_started or just_finished. if v.just_finished:
do_some_other_thing()
You can find how much time is left. As well as get a normalised
amount of time left(between 0. and 1.).
eg. time_before_powerup_runs_out = powerup_timer.left()
|
Methods
|
|
|
|
|
|
Update
|
Update ( self, elapsed_time )
Update(1.0) -> None
To be called on every game tic.
elapsed_time - since last update.
|
|
|
__eq__
|
__eq__ ( self, other )
|
|
|
__init__
|
__init__ (
self,
length,
callback=None,
)
length - of time to run for.
callback - optional callback function to call.
|
|
|
__ne__
|
__ne__ ( self, other )
|
|
|
__nonzero__
|
__nonzero__ ( self )
|
|
|
left
|
left ( self )
left() -> time left until finished.
|
|
|
left_normalised
|
left_normalised ( self )
left_normalised() -> the time left normalized to 0. - 1.
|
|
|
not_used
|
not_used ( self )
not_used -> None
For if the timer is not being used. This is useful for one time,
timers.
|
|
|
reset
|
reset ( self )
reset() -> None
Resets the timer to the beginning.
|
|
|
set_finished_no_callback
|
set_finished_no_callback ( self )
set_finished_no_callback() -> None
Sets it to finished, without calling callback. not just finished.
|
|