What I want is a possibility to create a function which play an
animation and does not return before tha animation is finished.
(Since the user gets an objects after this animation and shouldnt be
able to repeat that tooo fast.)
At the moment Im usign the following code which I dont really like
myself (since I need to know the length of the animation and everything
gets stuck for a second after the animation finished):
def play_blocking(self, animation):
# Backup the global idler and create a new one
# (which will become the global one immediately)
old_idler = soya.IDLER
idler = soya.Idler(game.scene)
# Thats a substitute for our begin_round-method,
# which simply counts a value down
def blockround():
soya.World.begin_round(self)
if self.wait_frames:
self.wait_frames -= 1
else:
# Okay, waited long enough, recover
# begin_round-function, stop our idler
# and reinstall the new one.
self.begin_round = self.begin_round_backup
soya.IDLER = old_idler
idler.stop()
self.begin_round_backup = self.begin_round
# Wait that much frames.
# Note: Blender uses 25 frames/sec, we should
# be somewhere around 40 (just too lazy to ask soya right now)
self.wait_frames = int(33 * 40.0/25.0)
self.begin_round = blockround
# Do the animation
self.perso.animate_execute_action(animation)
# This will return, when blockround() calls idler.stop()
idler.idle()
Henning
--
"Windows is a 64 bit tweak of a 32-bit extension to a 16-bit user
interface for an 8-bit operating system based on a 4-bit architecture
from a 2-bit company that can't stand 1 bit of competition."