Box2d Physics

Hi Developers & Ansca,

I have a quick question related to the Box2d Physics Engine in Corona.
I am in the making of a game, where I need to accomplish something similar to this: http://www.youtube.com/watch?v=EZcgkqEyErQ&feature=related, but where I have different sized boxes stacked on top of each other, then after some time the boxes will fall to the ground, but with same instability of the boxes, shown in the video. Is this possible in Corona? I have looked at the sample codes and tried to edit the code after my requirements, but with no luck.

Thank you very much in advance. [import]uid: 122802 topic_id: 21156 reply_id: 321156[/import]

This looks somewhat similar, maybe with a little tweaking you can get the desired results?

[lua]display.setStatusBar (display.HiddenStatusBar)

– Set up physics
require ( “physics” )
physics.start()
physics.setGravity( 0, 9.5 )
–physics.setDrawMode ( “hybrid” )

local bg = display.newRect( 0, 0, 320, 480 )
bg:setFillColor(0, 0, 0)

local ground = display.newRect( 0, 460, 320, 20 )
physics.addBody(ground, “static”, {density = 1.0, friction = 0.3, bounce = 0})

local function addBlock(event)
local block = display.newRect( event.x, event.y, 40, 40 )
physics.addBody(block, “dynamic”, {density = 1.0, friction = 0.3, bounce = 0.2})
end
bg:addEventListener(“tap”, addBlock)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 21156 reply_id: 83921[/import]

Hi :slight_smile:

That works very well, thank you very much for your help and your quick response.

[import]uid: 122802 topic_id: 21156 reply_id: 84179[/import]

You’re very welcome, happy to help!

Peach :slight_smile: [import]uid: 52491 topic_id: 21156 reply_id: 84228[/import]