Reference

addForce()

Description

Move an object through your PPhys2D world by adding a force vector to it. For exemple, in a platform game, add a vertical force to simulate jumping. If you are creating a space-shooter, you may want to use addForce to move your ship in a zero-gravity PPhys2D world.

Exemples

myBody.addForce(-200000, 0);

Syntax

addForce(float, float);

Parameters

x ->

float : the horizontal force to be applied (negative for left or positive for right).

y ->

float : the verticale force to be applied (negative for down or positive for up).