Skip to content Skip to sidebar Skip to footer

AndEngine: Use Of PIXEL_TO_METER_RATIO

I am new to AndEngine. I have seen use of PIXEL_TO_METER_RATIO in lot of places but not able to understand when and how this constant is used. Can anyone guide to the right directi

Solution 1:

Box2d, the underlying physics engine used by AndEngine, uses meters as standard units. PIXEL_TO_METER_RATIO describes how many pixels in AndEngine are equivalent to one meter in the physics engine. For example, if you get a position of the Body, it will be in meters. You would multiply it by the ratio to get a position on the Scene.


Solution 2:

the PTM_RATIO is defined because Box2D uses meters as standard units. for example, a screen of 480*320 pixels usually equals to a 15*10 square meters box2d world, if PTM_RATIO is defined as 32.


Box2D works with floating point numbers and tolerances have to be used to make Box2D perform well. These tolerances have been tuned to work well with meters-kilogram-second (MKS) units. In particular, Box2D has been tuned to work well with moving objects between 0.1 and 10 meters. So this means objects between soup cans and buses in size should work well. Static objects may be up to 50 meters big without too much trouble.


reference: http://www.box2d.org/manual.html


Post a Comment for "AndEngine: Use Of PIXEL_TO_METER_RATIO"