B2.setScale
Available since: Gideros 2011.6
Class: b2
Description
Box2D is tuned for MKS (meters-kilogram-second) units and the size of moving objects should be roughly between 0.1 and 10 meters.
If you directly use the pixels as your units, this will unfortunately lead to a poor simulation and possibly weird behavior.
Gideros uses an internal scale system to convert between meters and pixels. By default, the value of this scale is 30, which means 1 meter = 30 pixels. This is a global value and affects all the physics system. Therefore, it is recommended to set this value once before any physical objects are instantiated (e.g. right after calling require "box2d") <syntaxhighlight lang="lua"> b2.setScale(scale) </source>
Parameters
scale: (number) the global pixels to meters scale