AndEngine: using PIXEL_TO_METER_RATIO

I am new to AndEngine. I saw the use of PIXEL_TO_METER_RATIO in many places, but could not understand when and how this constant is used. Can anyone be guided in the right direction?

+4
source share
2 answers

Box2d, the main 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 the position of the body, it will be in meters. You must multiply it by a factor to get a position on the Stage.

+6
source

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


Box2D works with floating point numbers, and tolerances must be used for Box2D to work well. These tolerances have been tuned to work well with meter-kilogram (MKS) units. In particular, Box2D is configured to work well with moving objects from 0.1 to 10 meters. Thus, this means that the objects between the soup banks and the buses in size should work well. Static objects can be up to 50 meters without any problems.


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

+1
source

All Articles