[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Question about Pygame.event.wait and pygame.mixer.get_busy



On Mon, 06 Jun 2011 09:21 +0200, "Áron Ócsvári" <oaron1@xxxxxxxxx>
wrote:
>      while (pygame.mixer.get_busy()):
>          esemeny =pygame.event.wait()

Are you saying you want it to move on after the music is finished
playing, even if a button is not pressed? In which case the problem is
your second line. When it's reaches the pygame.event.wait() line, the
code will stop there and wait until an event happens, if you don't push
a button it never moves on, it never completes one iteration of the
loop.

You could change it to pygame.event.poll(), and then add in a
clock.tick(10) to limit the CPU usage. An alternative would be to get
the sound to emit an event when it finishes playing, which would move
your loop on, although I'm not sure if this is possible.

Thanks,
Sam Bull