Hey!
I’m trying to port one of my games to libgdx to make it playable with android devices. One problem I’ve encountered is the differences in using box2d: It seems like Codea is doing pixel-to-meter calculations in the background, I’'ve found the pixel-to-meter ratio (32) in the manual, but somehow box2d is still behaving differently in libgdx than in codea… …is there some more documentation on how exactly box-to-world/world-to-box calculation is done in Codea?
Box2d just moves objects etc within it’s coordinate system, if you just draw at those coordinates then it’s pixels to meters. If you want to get a different ratio then don’t use the coordinates raw to pixels, adjust them yourself.
eg
Ellipse(circleBody.x/ratio, circleBody.y/ratio) or some such.
@derhannes
Codea just multiplies and divides by the ratio so that 32 pixels on the screen = 1 meter within box2d. You can change the ratio but you’d want to do this before creating any physics objects. One thing that Codea does that might not be obvious is that it compensates for interpolation when using coordinate conversions so that you end up with smooth movement no matter how you derive coordinates. How is it behaving differently from libgdx?
Yes! Defining the PTM Ratio before making the body is the most important thing. That’s what I got wrong.