I want panda to show a animation, then exit.
I tried:
1–
play("animation")
sys.exit()
run
failed
2–
play("animation")
taskmgr.add(exit, "exit")
run()
failed
3–
taskmgr.add(play, "play")
taskmgr.add(exit, "exit")
run()
failed
How to exit when finishing the play animation?
I think what you would have to do is:
play(“animation”)
taskMgr.doMethodLater(0.1, self.check_animation_frame, “check”)
def check_animation_frame(self, task):
if [animation is playing]:
return Task.cont
taskMgr.doMethodLater(0.01, self.exit, “exit”)
return Task.done
def exit(self, task):
#do anything you feel like
sys.exit()
Double posted. Sorry. Slow connection.
play("animation")
taskMgr.doMethodLater(0.1, self.check_animation_frame, "check")
def check_animation_frame(self, task):
if [animation is playing]:
return Task.cont
taskMgr.doMethodLater(0.01, self.exit, "exit")
return Task.done
def exit(self, task):
#do anything you feel like
sys.exit()
An even slicker way would be to create an ActorInterval for the animation (see the manual- panda3d.org/manual/index.php/Actor_Intervals ), then build a sequence:
playSeq = Sequence(myActorInt, Func(sys.exit))