Type Function Object Body Library physics.* Return value none Revision Release 2024.3703 Keywords body, setLinearVelocity See also object:getLinearVelocity()
This function accepts x and y components for the body’s linear velocity, in pixels per second.
object:setLinearVelocity( xVelocity, yVelocity )
Numbers. Value for the velocity in the x and y directions respectively.
-- Create a rectangle local myRect = display.newRect( 0, 0, 100, 100 ) -- Add a body to the rectangle physics.addBody( myRect, "dynamic" ) -- Set the linear velocity myRect:setLinearVelocity( 10, 4 )