Difference between revisions of "B2.setScale"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
<languages />
'''<translate>Class</translate>:''' [[Special:MyLanguage/b2|b2]]<br/>
+
'''Available since:''' Gideros 2011.6<br/>
=== <translate>Description</translate> ===
+
'''Class:''' [[Special:MyLanguage/b2|b2]]<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 />
+
=== Description ===
If you directly use the pixels as your units, unfortunately this will lead to a poor simulation and possibly weird behavior.<br />
+
Box2D is tuned for MKS (meters-kilogram-second) units and the size of moving objects should be roughly between 0.1 and 10 meters.
<br />
+
 
Gideros uses an internal scale system to convert between meters and pixels. By default, the value of this scale is 30<br />
+
If you directly use the pixels as your units, this will unfortunately lead to a poor simulation and possibly weird behavior.
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 `require &quot;box2d&quot;`)<br />
+
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 &quot;box2d&quot;'')
<br /></translate>
+
<syntaxhighlight lang="lua">
<source lang="lua">
+
b2.setScale(scale)
b2.setScale(scale)
+
</syntaxhighlight>
</source>
+
 
=== <translate>Parameters</translate> ===
+
=== Parameters ===
'''scale''': (number) <translate>- the global pixels to meters scale</translate> <br/>
+
'''scale''': (number) the global pixels to meters scale <br/>
 +
 
 +
{{B2}}

Latest revision as of 14:26, 13 July 2023


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")

b2.setScale(scale)

Parameters

scale: (number) the global pixels to meters scale





LiquidFun