> It would appear you're running some form of event loop, such as
> wxpython, tkinter, pygame, or whatever.  If so, you have to do your
> delays using the mechanism that system defines, not using sleep().  As
> you've discovered, sleep() stops the whole thread, and that's not what
> you want.  What you want is to set an event to fire at some measured
> time in the future, so the actual waiting is done inside the event loop.
>

hey i looked at the livewires documentation and pulled up the timer
information. im struggling to figure out how to use its explanation. i
need to use it at 2 different parts of the program. 1st when the game
starts i need to create my sprite objects so they appear before my
animation objects:

red = Sprite(colour = Colours.red, x = 250, y = 255)
games.screen.add(red)

#timer event delay goes here so the animations don't start as soon as
the game is opened, before the coloured sprites as they've been doing.

self.create_animations()
---------------------------------------------


i also need a timer event when i display my sequence of animation
objects so they dont show on screen simultaneously. so:

#1st animation
red_animation = Animation(images = c_red, x = 250, y = 255,
                                         repeat_interval = 4, n_repeats = 1)
games.screen.add(red_ani)
red_sound.play()

#Timer event to go here, so next animation in sequence goes after the
timed pause.

#2nd animation
blue_animation = Animation(images = c_blue, x = 373, y = 255,
                                           repeat_interval = 4, n_repeats = 1)
games.screen.add(blue_ani)
blue_sound.play()

do you think you can offer any help how to implement the timer code or
function? i will provide the link to the page, but here's the relevant
code:


Timer
The Timer class is a class you can add to something which is also a
subclass of Object, to make an object that performs actions at regular
intervals. A class which is intended to be used with another class is
called a mix-in. For instance, if you wanted to make a new class of
your own which was a Circle and also a Timer, you would define the
class by saying class MyClass (games.Circle, games.Timer):
 • init_timer (interval)

interval is how often the tick method is called, measured in timer
ticks. How long a tick is depends on the fps argument you give to the
Screen‘s mainloop method. Setting fps to 50 means a tick is 1/50 of a
second.

You must call this method emph{after} you have called the init_ method
for the Object subclass you are using.

• stop ()

Stop the timer running. It continues to exist, but doesn’t count any more.

• start ()

Starts the timer again. A full interval will elapse before it ticks.

• get_interval ()

Gets the current interval.

• set_interval (interval)

Sets the current interval.

• tick ()

This method must be supplied by you, by subclassing the Timer class.

http://www.geon.wz.cz/livewires/w-livewires.html
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to