Difference between revisions of "B2.setScale"
From GiderosMobile
Line 2: | Line 2: | ||
'''Available since:''' Gideros 2011.6<br/> | '''Available since:''' Gideros 2011.6<br/> | ||
=== Description === | === Description === | ||
− | <br /> | + | <translate><br /> |
Box2D is tuned for MKS (meters-kilogram-second) units and the size of moving objects should roughly between 0.1 and 10 meters.<br /> | Box2D is tuned for MKS (meters-kilogram-second) units and the size of moving objects should roughly between 0.1 and 10 meters.<br /> | ||
If you directly use the pixels as your units, unfortunately this will lead to a poor simulation and possibly weird behavior.<br /> | If you directly use the pixels as your units, unfortunately this will lead to a poor simulation and possibly weird behavior.<br /> | ||
Line 8: | Line 8: | ||
Gideros uses an internal scale system to convert between meters and pixels. By default, the value of this scale is 30<br /> | Gideros uses an internal scale system to convert between meters and pixels. By default, the value of this scale is 30<br /> | ||
which means 1 meter = 30 pixels. This is a global value and effects all the physics system. Therefore, it is recommended to set this<br /> | which means 1 meter = 30 pixels. This is a global value and effects all the physics system. Therefore, it is recommended to set this<br /> | ||
− | value once before any physical objects are instantiated (e.g. right after calling | + | value once before any physical objects are instantiated (e.g. right after calling [[[require "box2d"]]])<br /> |
− | <br /> | + | <br /></translate> |
<source lang="lua"> | <source lang="lua"> | ||
b2.setScale(scale) | b2.setScale(scale) | ||
</source> | </source> | ||
=== Parameters === | === Parameters === | ||
− | '''scale''': (number) - the global pixels to meters scale <br/> | + | '''scale''': (number) <translate>- the global pixels to meters scale</translate> <br/> |
Revision as of 13:35, 23 August 2018
Available since: Gideros 2011.6
Description
Box2D is tuned for MKS (meters-kilogram-second) units and the size of moving objects should roughly between 0.1 and 10 meters.
If you directly use the pixels as your units, unfortunately this will 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 effects 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"]]])
b2.setScale(scale)
Parameters
scale: (number) - the global pixels to meters scale