physics2D.setGravity

Section: Physics 2D (Box2D)

What it does

physics2D.setGravity sets Gravity on a physics2D object. It takes x and y.

Signature

physics2D.setGravity(x, y)

Arguments

  • x
  • y

Example · generated

function update(dt) {  physics2D.setGravity(100, 120);}

physics2D.setGravity is called with values of the shape its signature asks for. The code sits in update(dt), which the engine calls every frame: dt is the time since the last one, in seconds.

7 members in physics2D