Removing msg handler when deleting entities?
Posted: Wed Jul 13, 2011 8:50 am
I have a Sphere (missile) that collides with a block(s).
In the collision handler thats called after the collision takes place I remove the sphere entity from the space and remove the event handler for the sphere.
Sometimes the sphere will collide with two blocks however so the handler is called a second time but at that point the handler has been removed (in the 1st call) so the Space.Update() throws an exception.
Is there a way to either flush out the message queue after the first collision?
or
How can I test for multiple contacts in the first collision?
Also am I correct in thinking that if I dont remove the handler when deleting the sphere it will never get cleaned up? Do I need to worry about this as not removing handler fixes the exception.
Thanks
In the collision handler thats called after the collision takes place I remove the sphere entity from the space and remove the event handler for the sphere.
Sometimes the sphere will collide with two blocks however so the handler is called a second time but at that point the handler has been removed (in the 1st call) so the Space.Update() throws an exception.
Is there a way to either flush out the message queue after the first collision?
or
How can I test for multiple contacts in the first collision?
Also am I correct in thinking that if I dont remove the handler when deleting the sphere it will never get cleaned up? Do I need to worry about this as not removing handler fixes the exception.
Thanks