Physics Object
From OxeyeWiki
The physics object in DaisyMoon is a wrapper around a Box2D instance. The wrapper controls Box2D entities (bodies with shapes and their collision data) and the Box2D physics world. Communication between DaisyMoon and the entities is done by handling body identifiers, which are simple integers.
For detailed documentation on how the physics work, please refer to the Box2D documentation.
Contents |
Concepts
World Resolution
The Box2D works with meters instead of pixels. In most cases this means that you need to convert coordinates when sending to or recieving from the physics object. From our experience, 32 pixels per meter is a good resolution to use.
local physResolution = 1 / 32 local nbrOfIterations = 10
Working with the Physics Object
Creating
physics = Physics(0, 0, width * physResolution, height * physResolution, gravityX, gravityY)
Updating
physics:update(timeStep, nbrOfIterations)