Hi. Sorry for double post. Didn’t know about the subscribers forum!
I have a strange problem.
If I create a dynamic object, add it to the physics and then place it on a static floor.
If I then change it’s bodyType to static and back to dynamic it “falls” a little “into” the floor before moving up again.
It moves a little more each time and finaly it falls thru!?
I’m kind of new to the Corona SDK, but I have seen similar posts regarding similar problems (same problem but when touching objects)
It seems the physics engine uses time to “grap” the body after the bodyType change??
A comment in the box2d thread provides this workaround: set your body’s active flag to false when you change the body type. Then on the next update, set it back to true again.
local physics = require("physics")physics.start()physics.setDrawMode("hybrid")local rect = display.newRect( display.contentCenterX, 400, 100, 100 )physics.addBody(rect, "dynamic")local floor = display.newRect( 0, 480, 320, 1 )physics.addBody(floor, "static")function changeMode( event ) if event.phase == "began" then local type = event.target.bodyType if type == "dynamic" then event.target.bodyType = "static" event.target.isBodyActive= false else event.target.bodyType = "dynamic" event.target.isBodyActive= true end endendrect:addEventListener("touch", changeMode)[/code]Tim [import]uid: 8196 topic_id: 8459 reply_id: 30448[/import]