Reference
- Body Classes
-
Body Functions
- (PPBox)getHeight()
- (PPBox)getWidth()
- (PPBox)setSize()
- (PPCircle)getSize()
- (PPCircle)setSize()
- addExcludedBody()
- addForce()
- adjustAngularVelocity()
- adjustVelocity()
- applyMatrix()
- attachImage()
- dettachImage()
- getAngularVelocity()
- getImageAlpha()
- getRotation()
- getVelocityX()
- getVelocityY()
- getX()
- getY()
- isResting()
- isStatic()
- isTouchingBody()
- resetForces()
- setAngularVelocity()
- setDamping()
- setDrawable()
- setFillColor()
- setFriction()
- setGravityEffected()
- setImageAlpha()
- setMass()
- setPosition()
- setRestitution()
- setRotatable()
- setRotation()
- setRotDamping()
- setStaticBody()
- setStrokeColor()
- setStrokeWidth()
- setVelocity()
- World Classes
- World Fucntions
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).