In my game, I store all my entities in an EntityManager object, which
references them in a couple different lists and dictionaries, for easy
database-like look-ups.  When a new entity is added, I dispatch the
"on_entity_added" event.  This event is handled by my Model object,
which in turn initializes the entity's Box2D body and pyglet sprite
objects.

This works great, except for the situation where I immediately call
the new entity's "start_moving" method.  This method attempts to apply
force to the uninitialized physics object, resulting in a thrown
exception.  This is because the event loop hasn't yet processes the
new event.

So what am I doing wrong here?  Should I replace the direct call to
the entity's method by an event, so the "start_moving" method isn't
executed until it's proper place in the event queue?  Or should I
replace the event-driven EntityManager with something that performs
all entity initialization immediately?

It seems like I should lean towards using events as much as possible,
but I'd like to hear what other people would do.

-- 
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.

Reply via email to