Static methods

@:native("apply_angular_impulse")staticapplyAngularImpulse(body:B2Body, impulse:Float):Void

  • Apply an angular impulse.

Parameters:

body

body

impulse

the angular impulse in units of kgmm/s

@:native("apply_force")staticapplyForce(body:B2Body, force:Vector3, point:Vector3):Void

  • Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.

Parameters:

body

body

force

the world force vector, usually in Newtons (N).

point

the world position of the point of application.

@:native("apply_force_to_center")staticapplyForceToCenter(body:B2Body, force:Vector3):Void

  • Apply a force to the center of mass. This wakes up the body.

Parameters:

body

body

force

the world force vector, usually in Newtons (N).

@:native("apply_linear_impulse")staticapplyLinearImpulse(body:B2Body, impulse:Vector3, point:Vector3):Void

  • Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.

Parameters:

body

body

impulse

the world impulse vector, usually in N-seconds or kg-m/s.

point

the world position of the point of application.

@:native("apply_torque")staticapplyTorque(body:B2Body, torque:Float):Void

  • Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.

Parameters:

body

body

torque

about the z-axis (out of the screen), usually in N-m.

@:native("get_angular_damping")staticgetAngularDamping(body:B2Body):Float

  • Get the angular damping of the body.

Parameters:

body

body

Returns:

the angular damping of the body.

@:native("get_angular_velocity")staticgetAngularVelocity(body:B2Body):Float

  • Get the angular velocity.

Parameters:

body

body

Returns:

the angular velocity in radians/second.

@:native("get_gravity_scale")staticgetGravityScale(body:B2Body):Float

  • Get the gravity scale of the body.

Parameters:

body

body

Returns:

the gravity scale of the body.

@:native("get_inertia")staticgetInertia(body:B2Body):Float

  • Get the rotational inertia of the body about the local origin.

Parameters:

body

body

Returns:

the rotational inertia, usually in kg-m^2.

@:native("get_linear_damping")staticgetLinearDamping(body:B2Body):Float

  • Get the linear damping of the body.

Parameters:

body

body

Returns:

the linear damping of the body.

@:native("get_linear_velocity")staticgetLinearVelocity(body:B2Body):Vector3

  • Get the linear velocity of the center of mass.

Parameters:

body

body

Returns:

the linear velocity of the center of mass.

@:native("get_local_center")staticgetLocalCenter(body:B2Body):Vector3

  • Get the local position of the center of mass.

Parameters:

body

body

Returns:

the local position of the center of mass.

@:native("get_local_point")staticgetLocalPoint(body:B2Body, world_point:Vector3):Vector3

  • Gets a local point relative to the body's origin given a world point.

Parameters:

body

body

world_point

a point in world coordinates.

Returns:

the corresponding local point relative to the body's origin.

@:native("get_local_vector")staticgetLocalVector(body:B2Body, world_vector:Vector3):Vector3

  • Gets a local vector given a world vector.

Parameters:

body

body

world_vector

a vector in world coordinates.

Returns:

the corresponding local vector.

@:native("get_mass")staticgetMass(body:B2Body):Float

  • Get the total mass of the body.

Parameters:

body

body

Returns:

the mass, usually in kilograms (kg).

@:native("get_position")staticgetPosition(body:B2Body):Vector3

  • Get the world body origin position.

Parameters:

body

body

Returns:

the world position of the body's origin.

@:native("get_rotation")staticgetRotation(body:B2Body):Float

  • Get the body rotation.

Parameters:

body

body

Returns:

the current world rotation angle in radians.

@:native("get_type")staticgetType(body:B2Body):B2BodyType

  • Get the body type. A dynamic body is fully simulated. Static bodies do not move. Kinematic bodies are not subject to forces but can move with a linear velocity.

Parameters:

body

body

Returns:

the body type: Static, Kinematic, or Dynamic

@:native("get_world")staticgetWorld(body:B2Body):B2World

  • Gets the Box2D world to which this body belongs.

Parameters:

body

body

Returns:

the world this body belongs to

@:native("get_world_center")staticgetWorldCenter(body:B2Body):Vector3

  • Get the world position of the center of mass.

Parameters:

body

body

Returns:

the world position of the center of mass.

@:native("get_world_point")staticgetWorldPoint(body:B2Body, local_point:Vector3):Vector3

  • Get the world coordinates of a point given the local coordinates.

Parameters:

body

body

local_point

a point on the body measured relative the body's origin.

Returns:

the same point expressed in world coordinates.

@:native("get_world_vector")staticgetWorldVector(body:B2Body, local_vector:Vector3):Vector3

  • Get the world coordinates of a vector given the local coordinates.

Parameters:

body

body

local_vector

a vector fixed in the body.

Returns:

the same vector expressed in world coordinates.

@:native("set_angular_damping")staticsetAngularDamping(body:B2Body, damping:Float):Void

  • Set the angular damping of the body.

Parameters:

body

body

damping

the new angular damping.

@:native("set_angular_velocity")staticsetAngularVelocity(body:B2Body, velocity:Float):Void

  • Set the angular velocity.

Parameters:

body

body

velocity

the new angular velocity in radians/second.

@:native("set_awake")staticsetAwake(body:B2Body, awake:Bool):Void

  • Set the sleep state of the body. A sleeping body has very low CPU cost.

Parameters:

body

body

awake

set to true to wake the body, false to put it to sleep.

@:native("set_bullet")staticsetBullet(body:B2Body, bullet:Bool):Void

  • Set the bullet state of the body. Bullet bodies are subject to continuous collision detection with dynamic bodies.

Parameters:

body

body

bullet

set to true to enable continuous collision detection with dynamic bodies.

@:native("set_fixed_rotation")staticsetFixedRotation(body:B2Body, fixed_rotation:Bool):Void

  • Set the fixed rotation state of the body. Fixed rotation bodies do not rotate.

Parameters:

body

body

fixed_rotation

set to true to prevent body from rotating.

@:native("set_gravity_scale")staticsetGravityScale(body:B2Body, scale:Float):Void

  • Set the gravity scale of the body.

Parameters:

body

body

scale

the new gravity scale.

@:native("set_linear_damping")staticsetLinearDamping(body:B2Body, damping:Float):Void

  • Set the linear damping of the body.

Parameters:

body

body

damping

the new linear damping.

@:native("set_linear_velocity")staticsetLinearVelocity(body:B2Body, velocity:Vector3):Void

  • Set the linear velocity of the center of mass.

Parameters:

body

body

velocity

the new linear velocity of the center of mass.

@:native("set_position")staticsetPosition(body:B2Body, position:Vector3):Void

  • Set the position of the body's origin.

Parameters:

body

body

position

the world position of the body's origin.

@:native("set_rotation")staticsetRotation(body:B2Body, angle:Float):Void

  • Set the body rotation.

Parameters:

body

body

angle

the new rotation angle in radians.

@:native("set_transform")staticsetTransform(body:B2Body, position:Vector3, angle:Float):Void

  • Set the position and angle of the body.

Parameters:

body

body

position

the world position of the body's origin.

angle

the world rotation angle in radians.

@:native("set_type")staticsetType(body:B2Body, type:B2BodyType):Void

  • Set the body type. A dynamic body is fully simulated. Static bodies do not move. Kinematic bodies are not subject to forces but can move with a linear velocity.

Parameters:

body

body

type

the body type: Static, Kinematic, or Dynamic