This is basically impossible.
On contact we can't destroy another object immediately since the contacts are processed (handle*Contact are called) when the Box2DContactListener receives an event from the world, which happens right in the middle of a world state.
To remedy that issue, which does not happen with nape because nape is either not as strict or made for this to be ok most of the time, I suggest processing contact only after the world step.
In fact it looks like this is how its typically done anyway.
Of course it would be nice to later have different update loops for CE or objects (similar to other platforms like fixed update? pre/post update, relative to physics maybe)
Anyway, this change means, any object destruction can be made instant, or in the same frame at least. To do that, MediatorState.as should collect "killed" objects after they've been updated, and not before as it is done now because objects are killed typically on interaction or in state's update... which means objects can still live at most 1 frame more than what they're supposed to , until the next update is called, however if in the same update we 1. update objects then 2. collect killed objects 3. and wait for the next frame, then killed objects will no longer have to live too long.
This is basically impossible. On contact we can't destroy another object immediately since the contacts are processed (handle*Contact are called) when the Box2DContactListener receives an event from the world, which happens right in the middle of a world state.
To remedy that issue, which does not happen with nape because nape is either not as strict or made for this to be ok most of the time, I suggest processing contact only after the world step.
In fact it looks like this is how its typically done anyway.
Here's the change : https://github.com/gsynuh/Citrus-Engine/commit/37805da8c70078eb2bafd1fa354ae6f58d2641f9
Of course it would be nice to later have different update loops for CE or objects (similar to other platforms like fixed update? pre/post update, relative to physics maybe)
Anyway, this change means, any object destruction can be made instant, or in the same frame at least. To do that, MediatorState.as should collect "killed" objects after they've been updated, and not before as it is done now because objects are killed typically on interaction or in state's update... which means objects can still live at most 1 frame more than what they're supposed to , until the next update is called, however if in the same update we 1. update objects then 2. collect killed objects 3. and wait for the next frame, then killed objects will no longer have to live too long.