Corona collision event handler and joints workaround
I am new to corona , and am trying to move a body over a path to reach some object "say an apple 4 example" , after it reaches the object i want to create a joint so that both move as a single object.
the problem is that i am using collision detection to detect that the moving body reaches the object , once a collision is detected the object and the body must be joined together , so i create a new joint . but this does not seem to work.
in the physics.newJoint() API it is remarked that it should not be used with the collision eventHnadler . deos anybody have an idea why is that ?? is it related to some physics or it is an issue or 开发者_如何学Ca bug ??
i tried to work it around but not using physics , so if anyone has an idea of how to work it around still with physics plz tell me .
Because changing anything about the physics model(s) during collision would interfere with the physics calculations for the current physics iteration, it throws a concurrent modification assertion - those objects are locked while they're figuring out how they're supposed to physically respond during that frame or sub-frame. It has to wait until the calculations are done or it gets spanked for interfering.
Workaround in ALL cases of modifying physics in the case of collision event handler is to add timer.performWithDelay(1, whatYouWannaDo, 1)
within the handler. This makes it wait until the program exits the event handler and then execute whatYouWannaDo
.
精彩评论