Type Function Object Body Library physics.* Return value none Revision Current Public Release (2015.2731) Keywords body, applyForce See also object:applyLinearImpulse() object:applyTorque() object:applyAngularImpulse()
A function that accepts x and y components of a linear force, applied at a given point with x and y world coordinates. If the target point is the body's center of mass, it will tend to push the body in a straight line; if the target is offset from the body's center of mass, the body will spin about its center of mass.
Note that the amount of force required to move heavy objects may need to be fairly high.
object:applyForce( xForce, yForce, bodyX, bodyY )
--Create a rectangle local myRect = display.newRect( 0, 0, 100, 100 ) --Add a body to the rectangle physics.addBody( myRect, "dynamic" ) myRect:applyForce( 50, 200, myRect.x, myRect.y )