main function
stringlengths 8
40
| chunks
stringlengths 41
8.32k
| repo_name
stringclasses 1
value |
---|---|---|
love.physics.newEdgeShape | love.physics.newEdgeShape
Creates a new EdgeShape.
shape = love.physics.newEdgeShape( x1, y1, x2, y2 )
x1 number The x position of the first point.
y1 number The y position of the first point.
x2 number The x position of the second point.
y2 number The y position of the second point.
shape EdgeShape The new shape. | love2d-community.github.io/love-api |
love.physics.newFixture | love.physics.newFixture
Creates and attaches a Fixture to a body.
Note that the Shape object is copied rather than kept as a reference when the Fixture is created. To get the Shape object that the Fixture owns, use Fixture:getShape.
fixture = love.physics.newFixture( body, shape, density )
body Body The body which gets the fixture attached.
shape Shape The shape to be copied to the fixture.
density (1) number The density of the fixture.
fixture Fixture The new fixture. | love2d-community.github.io/love-api |
love.physics.newFrictionJoint | love.physics.newFrictionJoint
Create a friction joint between two bodies. A FrictionJoint applies friction to a body.
joint = love.physics.newFrictionJoint( body1, body2, x, y, collideConnected )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
x number The x position of the anchor point.
y number The y position of the anchor point.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint FrictionJoint The new FrictionJoint.
joint = love.physics.newFrictionJoint( body1, body2, x1, y1, x2, y2, collideConnected )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
x1 number The x position of the first anchor point.
y1 number The y position of the first anchor point.
x2 number The x position of the second anchor point.
y2 number The y position of the second anchor point.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint FrictionJoint The new FrictionJoint. | love2d-community.github.io/love-api |
love.physics.newGearJoint | love.physics.newGearJoint
Create a GearJoint connecting two Joints.
The gear joint connects two joints that must be either prismatic or revolute joints. Using this joint requires that the joints it uses connect their respective bodies to the ground and have the ground as the first body. When destroying the bodies and joints you must make sure you destroy the gear joint before the other joints.
The gear joint has a ratio the determines how the angular or distance values of the connected joints relate to each other. The formula coordinate1 + ratio * coordinate2 always has a constant value that is set when the gear joint is created.
joint = love.physics.newGearJoint( joint1, joint2, ratio, collideConnected )
joint1 Joint The first joint to connect with a gear joint.
joint2 Joint The second joint to connect with a gear joint.
ratio (1) number The gear ratio.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint GearJoint The new gear joint. | love2d-community.github.io/love-api |
love.physics.newMotorJoint | love.physics.newMotorJoint
Creates a joint between two bodies which controls the relative motion between them.
Position and rotation offsets can be specified once the MotorJoint has been created, as well as the maximum motor force and torque that will be be applied to reach the target offsets.
joint = love.physics.newMotorJoint( body1, body2, correctionFactor )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
correctionFactor (0.3) number The joint's initial position correction factor, in the range of 1.
joint MotorJoint The new MotorJoint.
joint = love.physics.newMotorJoint( body1, body2, correctionFactor, collideConnected )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
correctionFactor (0.3) number The joint's initial position correction factor, in the range of 1.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint MotorJoint The new MotorJoint. | love2d-community.github.io/love-api |
love.physics.newMouseJoint | love.physics.newMouseJoint
Create a joint between a body and the mouse.
This joint actually connects the body to a fixed point in the world. To make it follow the mouse, the fixed point must be updated every timestep (example below).
The advantage of using a MouseJoint instead of just changing a body position directly is that collisions and reactions to other joints are handled by the physics engine.
joint = love.physics.newMouseJoint( body, x, y )
body Body The body to attach to the mouse.
x number The x position of the connecting point.
y number The y position of the connecting point.
joint MouseJoint The new mouse joint. | love2d-community.github.io/love-api |
love.physics.newPolygonShape | love.physics.newPolygonShape
Creates a new PolygonShape.
This shape can have 8 vertices at most, and must form a convex shape.
shape = love.physics.newPolygonShape( x1, y1, x2, y2, x3, y3, ... )
x1 number The x position of the first point.
y1 number The y position of the first point.
x2 number The x position of the second point.
y2 number The y position of the second point.
x3 number The x position of the third point.
y3 number The y position of the third point.
... number You can continue passing more point positions to create the PolygonShape.
shape PolygonShape A new PolygonShape.
shape = love.physics.newPolygonShape( vertices )
vertices table A list of vertices to construct the polygon, in the form of {x1, y1, x2, y2, x3, y3, ...}.
shape PolygonShape A new PolygonShape. | love2d-community.github.io/love-api |
love.physics.newPrismaticJoint | love.physics.newPrismaticJoint
Creates a PrismaticJoint between two bodies.
A prismatic joint constrains two bodies to move relatively to each other on a specified axis. It does not allow for relative rotation. Its definition and operation are similar to a revolute joint, but with translation and force substituted for angle and torque.
joint = love.physics.newPrismaticJoint( body1, body2, x, y, ax, ay, collideConnected )
body1 Body The first body to connect with a prismatic joint.
body2 Body The second body to connect with a prismatic joint.
x number The x coordinate of the anchor point.
y number The y coordinate of the anchor point.
ax number The x coordinate of the axis vector.
ay number The y coordinate of the axis vector.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint PrismaticJoint The new prismatic joint.
joint = love.physics.newPrismaticJoint( body1, body2, x1, y1, x2, y2, ax, ay, collideConnected )
body1 Body The first body to connect with a prismatic joint.
body2 Body The second body to connect with a prismatic joint.
x1 number The x coordinate of the first anchor point.
y1 number The y coordinate of the first anchor point.
x2 number The x coordinate of the second anchor point.
y2 number The y coordinate of the second anchor point.
ax number The x coordinate of the axis unit vector.
ay number The y coordinate of the axis unit vector.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint PrismaticJoint The new prismatic joint.
joint = love.physics.newPrismaticJoint( body1, body2, x1, y1, x2, y2, ax, ay, collideConnected, referenceAngle )
body1 Body The first body to connect with a prismatic joint.
body2 Body The second body to connect with a prismatic joint.
x1 number The x coordinate of the first anchor point.
y1 number The y coordinate of the first anchor point.
x2 number The x coordinate of the second anchor point.
y2 number The y coordinate of the second anchor point.
ax number The x coordinate of the axis unit vector.
ay number The y coordinate of the axis unit vector.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
referenceAngle (0) number The reference angle between body1 and body2, in radians.
joint PrismaticJoint The new prismatic joint. | love2d-community.github.io/love-api |
love.physics.newPulleyJoint | love.physics.newPulleyJoint
Creates a PulleyJoint to join two bodies to each other and the ground.
The pulley joint simulates a pulley with an optional block and tackle. If the ratio parameter has a value different from one, then the simulated rope extends faster on one side than the other. In a pulley joint the total length of the simulated rope is the constant length1 + ratio * length2, which is set when the pulley joint is created.
Pulley joints can behave unpredictably if one side is fully extended. It is recommended that the method setMaxLengths be used to constrain the maximum lengths each side can attain.
joint = love.physics.newPulleyJoint( body1, body2, gx1, gy1, gx2, gy2, x1, y1, x2, y2, ratio, collideConnected )
body1 Body The first body to connect with a pulley joint.
body2 Body The second body to connect with a pulley joint.
gx1 number The x coordinate of the first body's ground anchor.
gy1 number The y coordinate of the first body's ground anchor.
gx2 number The x coordinate of the second body's ground anchor.
gy2 number The y coordinate of the second body's ground anchor.
x1 number The x coordinate of the pulley joint anchor in the first body.
y1 number The y coordinate of the pulley joint anchor in the first body.
x2 number The x coordinate of the pulley joint anchor in the second body.
y2 number The y coordinate of the pulley joint anchor in the second body.
ratio (1) number The joint ratio.
collideConnected (true) boolean Specifies whether the two bodies should collide with each other.
joint PulleyJoint The new pulley joint. | love2d-community.github.io/love-api |
love.physics.newRectangleShape | love.physics.newRectangleShape
Shorthand for creating rectangular PolygonShapes.
By default, the local origin is located at the '''center''' of the rectangle as opposed to the top left for graphics.
shape = love.physics.newRectangleShape( width, height )
width number The width of the rectangle.
height number The height of the rectangle.
shape PolygonShape A new PolygonShape.
shape = love.physics.newRectangleShape( x, y, width, height, angle )
x number The offset along the x-axis.
y number The offset along the y-axis.
width number The width of the rectangle.
height number The height of the rectangle.
angle (0) number The initial angle of the rectangle.
shape PolygonShape A new PolygonShape. | love2d-community.github.io/love-api |
love.physics.newRevoluteJoint | love.physics.newRevoluteJoint
Creates a pivot joint between two bodies.
This joint connects two bodies to a point around which they can pivot.
joint = love.physics.newRevoluteJoint( body1, body2, x, y, collideConnected )
body1 Body The first body.
body2 Body The second body.
x number The x position of the connecting point.
y number The y position of the connecting point.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint RevoluteJoint The new revolute joint.
joint = love.physics.newRevoluteJoint( body1, body2, x1, y1, x2, y2, collideConnected, referenceAngle )
body1 Body The first body.
body2 Body The second body.
x1 number The x position of the first connecting point.
y1 number The y position of the first connecting point.
x2 number The x position of the second connecting point.
y2 number The y position of the second connecting point.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
referenceAngle (0) number The reference angle between body1 and body2, in radians.
joint RevoluteJoint The new revolute joint. | love2d-community.github.io/love-api |
love.physics.newRopeJoint | love.physics.newRopeJoint
Creates a joint between two bodies. Its only function is enforcing a max distance between these bodies.
joint = love.physics.newRopeJoint( body1, body2, x1, y1, x2, y2, maxLength, collideConnected )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
x1 number The x position of the first anchor point.
y1 number The y position of the first anchor point.
x2 number The x position of the second anchor point.
y2 number The y position of the second anchor point.
maxLength number The maximum distance for the bodies.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint RopeJoint The new RopeJoint. | love2d-community.github.io/love-api |
love.physics.newWeldJoint | love.physics.newWeldJoint
Creates a constraint joint between two bodies. A WeldJoint essentially glues two bodies together. The constraint is a bit soft, however, due to Box2D's iterative solver.
joint = love.physics.newWeldJoint( body1, body2, x, y, collideConnected )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
x number The x position of the anchor point (world space).
y number The y position of the anchor point (world space).
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint WeldJoint The new WeldJoint.
joint = love.physics.newWeldJoint( body1, body2, x1, y1, x2, y2, collideConnected )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
x1 number The x position of the first anchor point (world space).
y1 number The y position of the first anchor point (world space).
x2 number The x position of the second anchor point (world space).
y2 number The y position of the second anchor point (world space).
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint WeldJoint The new WeldJoint.
joint = love.physics.newWeldJoint( body1, body2, x1, y1, x2, y2, collideConnected, referenceAngle )
body1 Body The first body to attach to the joint.
body2 Body The second body to attach to the joint.
x1 number The x position of the first anchor point (world space).
y1 number The y position of the first anchor point (world space).
x2 number The x position of the second anchor point (world space).
y2 number The y position of the second anchor point (world space).
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
referenceAngle (0) number The reference angle between body1 and body2, in radians.
joint WeldJoint The new WeldJoint. | love2d-community.github.io/love-api |
love.physics.newWheelJoint | love.physics.newWheelJoint
Creates a wheel joint.
joint = love.physics.newWheelJoint( body1, body2, x, y, ax, ay, collideConnected )
body1 Body The first body.
body2 Body The second body.
x number The x position of the anchor point.
y number The y position of the anchor point.
ax number The x position of the axis unit vector.
ay number The y position of the axis unit vector.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint WheelJoint The new WheelJoint.
joint = love.physics.newWheelJoint( body1, body2, x1, y1, x2, y2, ax, ay, collideConnected )
body1 Body The first body.
body2 Body The second body.
x1 number The x position of the first anchor point.
y1 number The y position of the first anchor point.
x2 number The x position of the second anchor point.
y2 number The y position of the second anchor point.
ax number The x position of the axis unit vector.
ay number The y position of the axis unit vector.
collideConnected (false) boolean Specifies whether the two bodies should collide with each other.
joint WheelJoint The new WheelJoint. | love2d-community.github.io/love-api |
love.physics.newWorld | love.physics.newWorld
Creates a new World.
world = love.physics.newWorld( xg, yg, sleep )
xg (0) number The x component of gravity.
yg (0) number The y component of gravity.
sleep (true) boolean Whether the bodies in this world are allowed to sleep.
world World A brave new World. | love2d-community.github.io/love-api |
love.physics.setMeter | love.physics.setMeter
Sets the pixels to meter scale factor.
All coordinates in the physics module are divided by this number and converted to meters, and it creates a convenient way to draw the objects directly to the screen without the need for graphics transformations.
It is recommended to create shapes no larger than 10 times the scale. This is important because Box2D is tuned to work well with shape sizes from 0.1 to 10 meters. The default meter scale is 30.
love.physics.setMeter( scale )
scale number The scale factor as an integer. | love2d-community.github.io/love-api |
Body:applyAngularImpulse | Body:applyAngularImpulse
Applies an angular impulse to a body. This makes a single, instantaneous addition to the body momentum.
A body with with a larger mass will react less. The reaction does '''not''' depend on the timestep, and is equivalent to applying a force continuously for 1 second. Impulses are best used to give a single push to a body. For a continuous push to a body it is better to use Body:applyForce.
Body:applyAngularImpulse( impulse )
impulse number The impulse in kilogram-square meter per second. | love2d-community.github.io/love-api |
Body:applyForce | Body:applyForce
Apply force to a Body.
A force pushes a body in a direction. A body with with a larger mass will react less. The reaction also depends on how long a force is applied: since the force acts continuously over the entire timestep, a short timestep will only push the body for a short time. Thus forces are best used for many timesteps to give a continuous push to a body (like gravity). For a single push that is independent of timestep, it is better to use Body:applyLinearImpulse.
If the position to apply the force is not given, it will act on the center of mass of the body. The part of the force not directed towards the center of mass will cause the body to spin (and depends on the rotational inertia).
Note that the force components and position must be given in world coordinates.
Body:applyForce( fx, fy )
fx number The x component of force to apply to the center of mass.
fy number The y component of force to apply to the center of mass.
Body:applyForce( fx, fy, x, y )
fx number The x component of force to apply.
fy number The y component of force to apply.
x number The x position to apply the force.
y number The y position to apply the force. | love2d-community.github.io/love-api |
Body:applyLinearImpulse | Body:applyLinearImpulse
Applies an impulse to a body.
This makes a single, instantaneous addition to the body momentum.
An impulse pushes a body in a direction. A body with with a larger mass will react less. The reaction does '''not''' depend on the timestep, and is equivalent to applying a force continuously for 1 second. Impulses are best used to give a single push to a body. For a continuous push to a body it is better to use Body:applyForce.
If the position to apply the impulse is not given, it will act on the center of mass of the body. The part of the impulse not directed towards the center of mass will cause the body to spin (and depends on the rotational inertia).
Note that the impulse components and position must be given in world coordinates.
Body:applyLinearImpulse( ix, iy )
ix number The x component of the impulse applied to the center of mass.
iy number The y component of the impulse applied to the center of mass.
Body:applyLinearImpulse( ix, iy, x, y )
ix number The x component of the impulse.
iy number The y component of the impulse.
x number The x position to apply the impulse.
y number The y position to apply the impulse. | love2d-community.github.io/love-api |
Body:applyTorque | Body:applyTorque
Apply torque to a body.
Torque is like a force that will change the angular velocity (spin) of a body. The effect will depend on the rotational inertia a body has.
Body:applyTorque( torque )
torque number The torque to apply. | love2d-community.github.io/love-api |
Body:destroy | Body:destroy
Explicitly destroys the Body and all fixtures and joints attached to it.
An error will occur if you attempt to use the object after calling this function. In 0.7.2, when you don't have time to wait for garbage collection, this function may be used to free the object immediately.
Body:destroy() | love2d-community.github.io/love-api |
Body:getAngle | Body:getAngle
Get the angle of the body.
The angle is measured in radians. If you need to transform it to degrees, use math.deg.
A value of 0 radians will mean 'looking to the right'. Although radians increase counter-clockwise, the y axis points down so it becomes ''clockwise'' from our point of view.
angle = Body:getAngle()
angle number The angle in radians. | love2d-community.github.io/love-api |
Body:getAngularDamping | Body:getAngularDamping
Gets the Angular damping of the Body
The angular damping is the ''rate of decrease of the angular velocity over time'': A spinning body with no damping and no external forces will continue spinning indefinitely. A spinning body with damping will gradually stop spinning.
Damping is not the same as friction - they can be modelled together. However, only damping is provided by Box2D (and LOVE).
Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1.
damping = Body:getAngularDamping()
damping number The value of the angular damping. | love2d-community.github.io/love-api |
Body:getAngularVelocity | Body:getAngularVelocity
Get the angular velocity of the Body.
The angular velocity is the ''rate of change of angle over time''.
It is changed in World:update by applying torques, off centre forces/impulses, and angular damping. It can be set directly with Body:setAngularVelocity.
If you need the ''rate of change of position over time'', use Body:getLinearVelocity.
w = Body:getAngularVelocity()
w number The angular velocity in radians/second. | love2d-community.github.io/love-api |
Body:getContacts | Body:getContacts
Gets a list of all Contacts attached to the Body.
contacts = Body:getContacts()
contacts table A list with all contacts associated with the Body. | love2d-community.github.io/love-api |
Body:getFixtures | Body:getFixtures
Returns a table with all fixtures.
fixtures = Body:getFixtures()
fixtures table A sequence with all fixtures. | love2d-community.github.io/love-api |
Body:getGravityScale | Body:getGravityScale
Returns the gravity scale factor.
scale = Body:getGravityScale()
scale number The gravity scale factor. | love2d-community.github.io/love-api |
Body:getInertia | Body:getInertia
Gets the rotational inertia of the body.
The rotational inertia is how hard is it to make the body spin.
inertia = Body:getInertia()
inertia number The rotational inertial of the body. | love2d-community.github.io/love-api |
Body:getJoints | Body:getJoints
Returns a table containing the Joints attached to this Body.
joints = Body:getJoints()
joints table A sequence with the Joints attached to the Body. | love2d-community.github.io/love-api |
Body:getLinearDamping | Body:getLinearDamping
Gets the linear damping of the Body.
The linear damping is the ''rate of decrease of the linear velocity over time''. A moving body with no damping and no external forces will continue moving indefinitely, as is the case in space. A moving body with damping will gradually stop moving.
Damping is not the same as friction - they can be modelled together.
damping = Body:getLinearDamping()
damping number The value of the linear damping. | love2d-community.github.io/love-api |
Body:getLinearVelocity | Body:getLinearVelocity
Gets the linear velocity of the Body from its center of mass.
The linear velocity is the ''rate of change of position over time''.
If you need the ''rate of change of angle over time'', use Body:getAngularVelocity.
If you need to get the linear velocity of a point different from the center of mass:
* Body:getLinearVelocityFromLocalPoint allows you to specify the point in local coordinates.
* Body:getLinearVelocityFromWorldPoint allows you to specify the point in world coordinates.
See page 136 of 'Essential Mathematics for Games and Interactive Applications' for definitions of local and world coordinates.
x, y = Body:getLinearVelocity()
x number The x-component of the velocity vector
y number The y-component of the velocity vector | love2d-community.github.io/love-api |
Body:getLinearVelocityFromLocalPoint | Body:getLinearVelocityFromLocalPoint
Get the linear velocity of a point on the body.
The linear velocity for a point on the body is the velocity of the body center of mass plus the velocity at that point from the body spinning.
The point on the body must given in local coordinates. Use Body:getLinearVelocityFromWorldPoint to specify this with world coordinates.
vx, vy = Body:getLinearVelocityFromLocalPoint( x, y )
x number The x position to measure velocity.
y number The y position to measure velocity.
vx number The x component of velocity at point (x,y).
vy number The y component of velocity at point (x,y). | love2d-community.github.io/love-api |
Body:getLinearVelocityFromWorldPoint | Body:getLinearVelocityFromWorldPoint
Get the linear velocity of a point on the body.
The linear velocity for a point on the body is the velocity of the body center of mass plus the velocity at that point from the body spinning.
The point on the body must given in world coordinates. Use Body:getLinearVelocityFromLocalPoint to specify this with local coordinates.
vx, vy = Body:getLinearVelocityFromWorldPoint( x, y )
x number The x position to measure velocity.
y number The y position to measure velocity.
vx number The x component of velocity at point (x,y).
vy number The y component of velocity at point (x,y). | love2d-community.github.io/love-api |
Body:getLocalCenter | Body:getLocalCenter
Get the center of mass position in local coordinates.
Use Body:getWorldCenter to get the center of mass in world coordinates.
x, y = Body:getLocalCenter()
x number The x coordinate of the center of mass.
y number The y coordinate of the center of mass. | love2d-community.github.io/love-api |
Body:getLocalPoint | Body:getLocalPoint
Transform a point from world coordinates to local coordinates.
localX, localY = Body:getLocalPoint( worldX, worldY )
worldX number The x position in world coordinates.
worldY number The y position in world coordinates.
localX number The x position in local coordinates.
localY number The y position in local coordinates. | love2d-community.github.io/love-api |
Body:getLocalPoints | Body:getLocalPoints
Transforms multiple points from world coordinates to local coordinates.
x1, y1, x2, y2, ... = Body:getLocalPoints( x1, y1, x2, y2, ... )
x1 number (Argument) The x position of the first point.
y1 number (Argument) The y position of the first point.
x2 number (Argument) The x position of the second point.
y2 number (Argument) The y position of the second point.
... number (Argument) You can continue passing x and y position of the points.
x1 number (Result) The transformed x position of the first point.
y1 number (Result) The transformed y position of the first point.
x2 number (Result) The transformed x position of the second point.
y2 number (Result) The transformed y position of the second point.
... number (Result) Additional transformed x and y position of the points. | love2d-community.github.io/love-api |
Body:getLocalVector | Body:getLocalVector
Transform a vector from world coordinates to local coordinates.
localX, localY = Body:getLocalVector( worldX, worldY )
worldX number The vector x component in world coordinates.
worldY number The vector y component in world coordinates.
localX number The vector x component in local coordinates.
localY number The vector y component in local coordinates. | love2d-community.github.io/love-api |
Body:getMass | Body:getMass
Get the mass of the body.
Static bodies always have a mass of 0.
mass = Body:getMass()
mass number The mass of the body (in kilograms). | love2d-community.github.io/love-api |
Body:getMassData | Body:getMassData
Returns the mass, its center, and the rotational inertia.
x, y, mass, inertia = Body:getMassData()
x number The x position of the center of mass.
y number The y position of the center of mass.
mass number The mass of the body.
inertia number The rotational inertia. | love2d-community.github.io/love-api |
Body:getPosition | Body:getPosition
Get the position of the body.
Note that this may not be the center of mass of the body.
x, y = Body:getPosition()
x number The x position.
y number The y position. | love2d-community.github.io/love-api |
Body:getTransform | Body:getTransform
Get the position and angle of the body.
Note that the position may not be the center of mass of the body. An angle of 0 radians will mean 'looking to the right'. Although radians increase counter-clockwise, the y axis points down so it becomes clockwise from our point of view.
x, y, angle = Body:getTransform()
x number The x component of the position.
y number The y component of the position.
angle number The angle in radians. | love2d-community.github.io/love-api |
Body:getType | Body:getType
Returns the type of the body.
type = Body:getType()
type BodyType The body type. | love2d-community.github.io/love-api |
Body:getUserData | Body:getUserData
Returns the Lua value associated with this Body.
value = Body:getUserData()
value any The Lua value associated with the Body. | love2d-community.github.io/love-api |
Body:getWorld | Body:getWorld
Gets the World the body lives in.
world = Body:getWorld()
world World The world the body lives in. | love2d-community.github.io/love-api |
Body:getWorldCenter | Body:getWorldCenter
Get the center of mass position in world coordinates.
Use Body:getLocalCenter to get the center of mass in local coordinates.
x, y = Body:getWorldCenter()
x number The x coordinate of the center of mass.
y number The y coordinate of the center of mass. | love2d-community.github.io/love-api |
Body:getWorldPoint | Body:getWorldPoint
Transform a point from local coordinates to world coordinates.
worldX, worldY = Body:getWorldPoint( localX, localY )
localX number The x position in local coordinates.
localY number The y position in local coordinates.
worldX number The x position in world coordinates.
worldY number The y position in world coordinates. | love2d-community.github.io/love-api |
Body:getWorldPoints | Body:getWorldPoints
Transforms multiple points from local coordinates to world coordinates.
x1, y1, x2, y2 = Body:getWorldPoints( x1, y1, x2, y2 )
x1 number The x position of the first point.
y1 number The y position of the first point.
x2 number The x position of the second point.
y2 number The y position of the second point.
x1 number The transformed x position of the first point.
y1 number The transformed y position of the first point.
x2 number The transformed x position of the second point.
y2 number The transformed y position of the second point. | love2d-community.github.io/love-api |
Body:getWorldVector | Body:getWorldVector
Transform a vector from local coordinates to world coordinates.
worldX, worldY = Body:getWorldVector( localX, localY )
localX number The vector x component in local coordinates.
localY number The vector y component in local coordinates.
worldX number The vector x component in world coordinates.
worldY number The vector y component in world coordinates. | love2d-community.github.io/love-api |
Body:getX | Body:getX
Get the x position of the body in world coordinates.
x = Body:getX()
x number The x position in world coordinates. | love2d-community.github.io/love-api |
Body:getY | Body:getY
Get the y position of the body in world coordinates.
y = Body:getY()
y number The y position in world coordinates. | love2d-community.github.io/love-api |
Body:isActive | Body:isActive
Returns whether the body is actively used in the simulation.
status = Body:isActive()
status boolean True if the body is active or false if not. | love2d-community.github.io/love-api |
Body:isAwake | Body:isAwake
Returns the sleep status of the body.
status = Body:isAwake()
status boolean True if the body is awake or false if not. | love2d-community.github.io/love-api |
Body:isBullet | Body:isBullet
Get the bullet status of a body.
There are two methods to check for body collisions:
* at their location when the world is updated (default)
* using continuous collision detection (CCD)
The default method is efficient, but a body moving very quickly may sometimes jump over another body without producing a collision. A body that is set as a bullet will use CCD. This is less efficient, but is guaranteed not to jump when moving quickly.
Note that static bodies (with zero mass) always use CCD, so your walls will not let a fast moving body pass through even if it is not a bullet.
status = Body:isBullet()
status boolean The bullet status of the body. | love2d-community.github.io/love-api |
Body:isDestroyed | Body:isDestroyed
Gets whether the Body is destroyed. Destroyed bodies cannot be used.
destroyed = Body:isDestroyed()
destroyed boolean Whether the Body is destroyed. | love2d-community.github.io/love-api |
Body:isFixedRotation | Body:isFixedRotation
Returns whether the body rotation is locked.
fixed = Body:isFixedRotation()
fixed boolean True if the body's rotation is locked or false if not. | love2d-community.github.io/love-api |
Body:isSleepingAllowed | Body:isSleepingAllowed
Returns the sleeping behaviour of the body.
allowed = Body:isSleepingAllowed()
allowed boolean True if the body is allowed to sleep or false if not. | love2d-community.github.io/love-api |
Body:isTouching | Body:isTouching
Gets whether the Body is touching the given other Body.
touching = Body:isTouching( otherbody )
otherbody Body The other body to check.
touching boolean True if this body is touching the other body, false otherwise. | love2d-community.github.io/love-api |
Body:resetMassData | Body:resetMassData
Resets the mass of the body by recalculating it from the mass properties of the fixtures.
Body:resetMassData() | love2d-community.github.io/love-api |
Body:setActive | Body:setActive
Sets whether the body is active in the world.
An inactive body does not take part in the simulation. It will not move or cause any collisions.
Body:setActive( active )
active boolean If the body is active or not. | love2d-community.github.io/love-api |
Body:setAngle | Body:setAngle
Set the angle of the body.
The angle is measured in radians. If you need to transform it from degrees, use math.rad.
A value of 0 radians will mean 'looking to the right'. Although radians increase counter-clockwise, the y axis points down so it becomes ''clockwise'' from our point of view.
It is possible to cause a collision with another body by changing its angle.
Body:setAngle( angle )
angle number The angle in radians. | love2d-community.github.io/love-api |
Body:setAngularDamping | Body:setAngularDamping
Sets the angular damping of a Body
See Body:getAngularDamping for a definition of angular damping.
Angular damping can take any value from 0 to infinity. It is recommended to stay between 0 and 0.1, though. Other values will look unrealistic.
Body:setAngularDamping( damping )
damping number The new angular damping. | love2d-community.github.io/love-api |
Body:setAngularVelocity | Body:setAngularVelocity
Sets the angular velocity of a Body.
The angular velocity is the ''rate of change of angle over time''.
This function will not accumulate anything; any impulses previously applied since the last call to World:update will be lost.
Body:setAngularVelocity( w )
w number The new angular velocity, in radians per second | love2d-community.github.io/love-api |
Body:setAwake | Body:setAwake
Wakes the body up or puts it to sleep.
Body:setAwake( awake )
awake boolean The body sleep status. | love2d-community.github.io/love-api |
Body:setBullet | Body:setBullet
Set the bullet status of a body.
There are two methods to check for body collisions:
* at their location when the world is updated (default)
* using continuous collision detection (CCD)
The default method is efficient, but a body moving very quickly may sometimes jump over another body without producing a collision. A body that is set as a bullet will use CCD. This is less efficient, but is guaranteed not to jump when moving quickly.
Note that static bodies (with zero mass) always use CCD, so your walls will not let a fast moving body pass through even if it is not a bullet.
Body:setBullet( status )
status boolean The bullet status of the body. | love2d-community.github.io/love-api |
Body:setFixedRotation | Body:setFixedRotation
Set whether a body has fixed rotation.
Bodies with fixed rotation don't vary the speed at which they rotate. Calling this function causes the mass to be reset.
Body:setFixedRotation( isFixed )
isFixed boolean Whether the body should have fixed rotation. | love2d-community.github.io/love-api |
Body:setGravityScale | Body:setGravityScale
Sets a new gravity scale factor for the body.
Body:setGravityScale( scale )
scale number The new gravity scale factor. | love2d-community.github.io/love-api |
Body:setInertia | Body:setInertia
Set the inertia of a body.
Body:setInertia( inertia )
inertia number The new moment of inertia, in kilograms * pixel squared. | love2d-community.github.io/love-api |
Body:setLinearDamping | Body:setLinearDamping
Sets the linear damping of a Body
See Body:getLinearDamping for a definition of linear damping.
Linear damping can take any value from 0 to infinity. It is recommended to stay between 0 and 0.1, though. Other values will make the objects look 'floaty'(if gravity is enabled).
Body:setLinearDamping( ld )
ld number The new linear damping | love2d-community.github.io/love-api |
Body:setLinearVelocity | Body:setLinearVelocity
Sets a new linear velocity for the Body.
This function will not accumulate anything; any impulses previously applied since the last call to World:update will be lost.
Body:setLinearVelocity( x, y )
x number The x-component of the velocity vector.
y number The y-component of the velocity vector. | love2d-community.github.io/love-api |
Body:setMass | Body:setMass
Sets a new body mass.
Body:setMass( mass )
mass number The mass, in kilograms. | love2d-community.github.io/love-api |
Body:setMassData | Body:setMassData
Overrides the calculated mass data.
Body:setMassData( x, y, mass, inertia )
x number The x position of the center of mass.
y number The y position of the center of mass.
mass number The mass of the body.
inertia number The rotational inertia. | love2d-community.github.io/love-api |
Body:setPosition | Body:setPosition
Set the position of the body.
Note that this may not be the center of mass of the body.
This function cannot wake up the body.
Body:setPosition( x, y )
x number The x position.
y number The y position. | love2d-community.github.io/love-api |
Body:setSleepingAllowed | Body:setSleepingAllowed
Sets the sleeping behaviour of the body. Should sleeping be allowed, a body at rest will automatically sleep. A sleeping body is not simulated unless it collided with an awake body. Be wary that one can end up with a situation like a floating sleeping body if the floor was removed.
Body:setSleepingAllowed( allowed )
allowed boolean True if the body is allowed to sleep or false if not. | love2d-community.github.io/love-api |
Body:setTransform | Body:setTransform
Set the position and angle of the body.
Note that the position may not be the center of mass of the body. An angle of 0 radians will mean 'looking to the right'. Although radians increase counter-clockwise, the y axis points down so it becomes clockwise from our point of view.
This function cannot wake up the body.
Body:setTransform( x, y, angle )
x number The x component of the position.
y number The y component of the position.
angle number The angle in radians. | love2d-community.github.io/love-api |
Body:setType | Body:setType
Sets a new body type.
Body:setType( type )
type BodyType The new type. | love2d-community.github.io/love-api |
Body:setUserData | Body:setUserData
Associates a Lua value with the Body.
To delete the reference, explicitly pass nil.
Body:setUserData( value )
value any The Lua value to associate with the Body. | love2d-community.github.io/love-api |
Body:setX | Body:setX
Set the x position of the body.
This function cannot wake up the body.
Body:setX( x )
x number The x position. | love2d-community.github.io/love-api |
Body:setY | Body:setY
Set the y position of the body.
This function cannot wake up the body.
Body:setY( y )
y number The y position. | love2d-community.github.io/love-api |
ChainShape:getChildEdge | ChainShape:getChildEdge
Returns a child of the shape as an EdgeShape.
shape = ChainShape:getChildEdge( index )
index number The index of the child.
shape EdgeShape The child as an EdgeShape. | love2d-community.github.io/love-api |
ChainShape:getNextVertex | ChainShape:getNextVertex
Gets the vertex that establishes a connection to the next shape.
Setting next and previous ChainShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape.
x, y = ChainShape:getNextVertex()
x number The x-component of the vertex, or nil if ChainShape:setNextVertex hasn't been called.
y number The y-component of the vertex, or nil if ChainShape:setNextVertex hasn't been called. | love2d-community.github.io/love-api |
ChainShape:getPoint | ChainShape:getPoint
Returns a point of the shape.
x, y = ChainShape:getPoint( index )
index number The index of the point to return.
x number The x-coordinate of the point.
y number The y-coordinate of the point. | love2d-community.github.io/love-api |
ChainShape:getPoints | ChainShape:getPoints
Returns all points of the shape.
x1, y1, x2, y2 = ChainShape:getPoints()
x1 number The x-coordinate of the first point.
y1 number The y-coordinate of the first point.
x2 number The x-coordinate of the second point.
y2 number The y-coordinate of the second point. | love2d-community.github.io/love-api |
ChainShape:getPreviousVertex | ChainShape:getPreviousVertex
Gets the vertex that establishes a connection to the previous shape.
Setting next and previous ChainShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape.
x, y = ChainShape:getPreviousVertex()
x number The x-component of the vertex, or nil if ChainShape:setPreviousVertex hasn't been called.
y number The y-component of the vertex, or nil if ChainShape:setPreviousVertex hasn't been called. | love2d-community.github.io/love-api |
ChainShape:getVertexCount | ChainShape:getVertexCount
Returns the number of vertices the shape has.
count = ChainShape:getVertexCount()
count number The number of vertices. | love2d-community.github.io/love-api |
ChainShape:setNextVertex | ChainShape:setNextVertex
Sets a vertex that establishes a connection to the next shape.
This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape.
ChainShape:setNextVertex( x, y )
x number The x-component of the vertex.
y number The y-component of the vertex. | love2d-community.github.io/love-api |
ChainShape:setPreviousVertex | ChainShape:setPreviousVertex
Sets a vertex that establishes a connection to the previous shape.
This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape.
ChainShape:setPreviousVertex( x, y )
x number The x-component of the vertex.
y number The y-component of the vertex. | love2d-community.github.io/love-api |
CircleShape:getPoint | CircleShape:getPoint
Gets the center point of the circle shape.
x, y = CircleShape:getPoint()
x number The x-component of the center point of the circle.
y number The y-component of the center point of the circle. | love2d-community.github.io/love-api |
CircleShape:getRadius | CircleShape:getRadius
Gets the radius of the circle shape.
radius = CircleShape:getRadius()
radius number The radius of the circle | love2d-community.github.io/love-api |
CircleShape:setPoint | CircleShape:setPoint
Sets the location of the center of the circle shape.
CircleShape:setPoint( x, y )
x number The x-component of the new center point of the circle.
y number The y-component of the new center point of the circle. | love2d-community.github.io/love-api |
CircleShape:setRadius | CircleShape:setRadius
Sets the radius of the circle.
CircleShape:setRadius( radius )
radius number The radius of the circle | love2d-community.github.io/love-api |
Contact:getChildren | Contact:getChildren
Gets the child indices of the shapes of the two colliding fixtures. For ChainShapes, an index of 1 is the first edge in the chain. Used together with Fixture:rayCast or ChainShape:getChildEdge.
indexA, indexB = Contact:getChildren()
indexA number The child index of the first fixture's shape.
indexB number The child index of the second fixture's shape. | love2d-community.github.io/love-api |
Contact:getFixtures | Contact:getFixtures
Gets the two Fixtures that hold the shapes that are in contact.
fixtureA, fixtureB = Contact:getFixtures()
fixtureA Fixture The first Fixture.
fixtureB Fixture The second Fixture. | love2d-community.github.io/love-api |
Contact:getFriction | Contact:getFriction
Get the friction between two shapes that are in contact.
friction = Contact:getFriction()
friction number The friction of the contact. | love2d-community.github.io/love-api |
Contact:getNormal | Contact:getNormal
Get the normal vector between two shapes that are in contact.
This function returns the coordinates of a unit vector that points from the first shape to the second.
nx, ny = Contact:getNormal()
nx number The x component of the normal vector.
ny number The y component of the normal vector. | love2d-community.github.io/love-api |
Contact:getPositions | Contact:getPositions
Returns the contact points of the two colliding fixtures. There can be one or two points.
x1, y1, x2, y2 = Contact:getPositions()
x1 number The x coordinate of the first contact point.
y1 number The y coordinate of the first contact point.
x2 number The x coordinate of the second contact point.
y2 number The y coordinate of the second contact point. | love2d-community.github.io/love-api |
Contact:getRestitution | Contact:getRestitution
Get the restitution between two shapes that are in contact.
restitution = Contact:getRestitution()
restitution number The restitution between the two shapes. | love2d-community.github.io/love-api |
Contact:isEnabled | Contact:isEnabled
Returns whether the contact is enabled. The collision will be ignored if a contact gets disabled in the preSolve callback.
enabled = Contact:isEnabled()
enabled boolean True if enabled, false otherwise. | love2d-community.github.io/love-api |
Contact:isTouching | Contact:isTouching
Returns whether the two colliding fixtures are touching each other.
touching = Contact:isTouching()
touching boolean True if they touch or false if not. | love2d-community.github.io/love-api |
Contact:resetFriction | Contact:resetFriction
Resets the contact friction to the mixture value of both fixtures.
Contact:resetFriction() | love2d-community.github.io/love-api |
Contact:resetRestitution | Contact:resetRestitution
Resets the contact restitution to the mixture value of both fixtures.
Contact:resetRestitution() | love2d-community.github.io/love-api |