Physics and zooming / scaling

Hello there !

So, I’m trying to implement a zoom function in my physics based game, scaling the whole thing. Unfortunately, my display objects are actually resized but the physics forms are not. Even if I insert everything in a whole new group.

This is basically what I have done, and it doesn’t work :

[lua]physics = require “physics”

physics.start();

physics.setDrawMode(“hybrid”)

local World = display.newGroup()

local square1 = display.newRect(0,0, 200,200)

square1:setFillColor(255,255,255,255)

physics.addBody(square1, “static”)

local square2 = display.newRect(300,300, 200,200)

square2:setFillColor(255,255,255,255)

physics.addBody(square2, “static”)

World:insert(square1)

World:insert(square2)

World:scale(0.2,0.2)[/lua]

I’ve understood the fact that Corona SDK doesn’t rescale physics body object… But, is there any way or workaround to do this ?

Thank you !

There is a very old Corona bug, going back years, where the display of physics bodies in hybrid or debug mode won’t scale correctly if you scale the group.  The _actual _physics bodies used by the simulation are scaling just fine under the hood so your simulation should be ok, although the bug makes debug and hybrid modes kind of useless for their intended purpose if you scale the world.  

Oooh… Thank you so much ! Can’t believe I did’t notice that it actually worked…

Thanks again for your answer !

There is a very old Corona bug, going back years, where the display of physics bodies in hybrid or debug mode won’t scale correctly if you scale the group.  The _actual _physics bodies used by the simulation are scaling just fine under the hood so your simulation should be ok, although the bug makes debug and hybrid modes kind of useless for their intended purpose if you scale the world.  

Oooh… Thank you so much ! Can’t believe I did’t notice that it actually worked…

Thanks again for your answer !