Hi, is it possible to change type of phisical body in function onEnterFrame()
For example I want to stick 2 objects like at this preview:
http://www.freeimagehosting.net/d149fI detect collision but don't know how to stick it...
Have you any ideas how to solve this solution?
Comments
You need to create weld joint to stick them together.
Dynamic Object - actors[1].body
Creation weld joint on collision enter:
Expression IsLocked == false
When I use this code "onButtonPress" - than it works, else - fatal error..
Works not so well! help to find my error
Box2d locks the world while it dispatches events BEGIN_CONTACT, END_CONTACT, PRE_SOLVE and POST_SOLVE. And if the world is locked, these functions give assertion:
b2.World:createBody
b2.World:destroyBody
b2.World:createJoint
b2.World:destroyJoint
b2.Body:createFixture
b2.Body:destroyFixture
b2.Body:setActive
b2.Body:setPosition
For your case, the solution is to create your joint outside of these events. (For example, you can set a flag and check this flag on ENTER_FRAME and if it's true create your joint)
I mean set a flag on onBeginContact function and test this flag on onEnterFrame, if true create your weld joint.