Defold
b2d
Functions for interacting with Box2D.
Functions
b2d.get_body(url: string | Hash | Url): Opaque<"b2Body"> | undefined
Get the Box2D body from a collision object
Parameters
url:string | Hash | Url— the url to the game object collision component
Returns
body:Opaque<"b2Body"> | undefined— the body if successful. Otherwisenil.
b2d.get_gameobject_id(body: Opaque<"b2Body">): Hash | undefinedN
- Since Defold 1.14.0
Returns the id of the game object that owns the body's collision-object component. Raises a Lua error if the body handle is invalid or its game object has been deleted.
const body = b2d.get_body("#collisionobject");
if (body !== undefined) {
const id = b2d.get_gameobject_id(body);
}local body = b2d.get_body("#collisionobject")
local id = b2d.get_gameobject_id(body)Parameters
body:Opaque<"b2Body">— the Box2D body
Returns
id:Hash | undefined— the game object id, ornilif the body has no associated game object
b2d.get_version(): b2d.VersionInfoN
- Since Defold 1.13.0
Get the Box2D version information for the active backend.
Returns
info:b2d.VersionInfo— version information
b2d.get_world(): Opaque<"b2World"> | undefinedC
Signature changed in Defold 1.13.2 — before:
(): Opaque<"b2World">
Get the Box2D world from the current collection
Returns
world:Opaque<"b2World"> | undefined— the world if successful. Otherwisenil.