On Fri, Mar 7, 2008 at 4:34 PM, Juan Jose Alonso <[EMAIL PROTECTED]> wrote: > > Hello goys, recently i discover that my engine structure dont run fine > here in pyglet, my engine loop change the scenes capturing a > ChangeScene, is a elegant method, then i have this.. > > def run(self, scene): > self.scene = scene() > self.scene.init() > while not self.window.has_exit: > try: > self.window.clear() > self.window.dispatch_events() > self.scene.update() > self.scene.render() > self.window.flip() > self.clock.tick() > except ChangeScene, e: > self.scene = e() > self.scene.init() > > > i have this method for my window key press event: > > def on_key_press(self, symbol, modifiers): > raise ChangeScene, MyNewScene > > > I discover that the exception is not captured, because i think that > dispath_events not the flow that call the events callbacks... then... > how i can fix this? also think that is a good change in the new > pyglet? >
This isn't the right way (TM) to generate events in pyglet. You should leverage pyglet's event subsystem and create a custom ChangeSceneEvent (vs. using an Exception as you're currently trying to do): http://pyglet.org/doc/programming_guide/the_pyglet_event_framework.html -- \\\\\/\"/\\\\\\\\\\\ \\\\/ // //\/\\\\\\\ \\\/ \\// /\ \/\\\\ \\/ /\/ / /\/ /\ \\\ \/ / /\/ /\ /\\\ \\ / /\\\ /\\\ \\\\\/\ \/\\\\\/\\\\\/\\\\\\ d.p.s --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
