Difference between revisions of "love.physics"

(Types)
m
 
(23 intermediate revisions by 17 users not shown)
Line 1: Line 1:
Can simulate 2D rigid body physics in a realistic manner.
+
{{newin|[[0.4.0]]|040|type=module}}
This module is based on [http://www.box2d.org/ Box2D], and this API corresponds to the [http://www.box2d.org/manual.html Box2D API] as closely as possible.
+
Can simulate 2D rigid bodies in a realistic manner. This module is essentially just a binding to [http://box2d.org/about/ Box2D] (version 2.3.0 - [https://box2d.org/documentation/ manual]).
{{notice|Love.physics is not lightweight, and not even remotely simple to use. Its a ten-ton hammer designed for heavy-lifting (er...hammer...lifting?).
+
 
If you are just trying to make a character jump around on blocks or the likes, then move along, nothing to see here.}}
+
For simpler (and more common) use cases, a small number of libraries exist, which are usually more popularly used than love.physics and can be found here: https://github.com/love2d-community/awesome-love2d#physics
  
 
== Types ==
 
== Types ==
{{#ask: [[Category:Types]] [[parent::love.physics]]
+
{{#ask: [[Category:Types]] [[parent::love.physics]] [[Concept:Current]]
 
| headers=hide
 
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 
| ?Description
 
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 
}}
 
}}
Можно моделировать 2D физику жесткого тела в реалистической манере. Этот модуль основан на Box2D, и это API соответствует Box2D API, насколько это возможно.
 
 
Love.physics не легок, и даже отдаленно не прост в использовании.
 
 
Если вы просто пытаетесь сделать прыгающего человечка на блоки или заставить его то двигаться вперед, этот раздел не для вас.
 
 
 
== Functions ==
 
== Functions ==
{{#ask: [[Category:Functions]] [[parent::love.physics]]
+
{{#ask: [[Category:Functions]] [[parent::love.physics]] [[Concept:Current]]
 
| headers=hide
 
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 
| ?Description
 
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 
}}
 
}}
[[Category:Modules]]
+
== Enums ==
{{#set:Description=Can simulate 2D rigid body physics in a realistic manner.
+
{{#ask: [[Category:Enums]] [[parent::love.physics]] [[Concept:Current]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 
}}
 
}}
 +
 +
== Notes ==
 +
=== Box2D's architecture, concepts, and terminologies. ===
 +
[[File:Box2D basic overview.png|880px]]
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]
 
* [[Tutorial:Physics]]
 
* [[Tutorial:Physics]]
 +
* [[Tutorial:PhysicsCollisionCallbacks]]
 +
* [http://www.iforce2d.net/b2dtut/gotchas Box2D Gotchas] (recommended reading)
 +
 +
[[Category:Modules]]
 +
{{#set:Description=Can simulate 2D rigid body physics in a realistic manner.}}
 +
{{#set:Since=040}}
 +
{{#set:PrettySince=0.4.0}}
  
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.physics}}
 
{{i18n|love.physics}}

Latest revision as of 21:05, 15 June 2020

Available since LÖVE 0.4.0
This module is not supported in earlier versions.

Can simulate 2D rigid bodies in a realistic manner. This module is essentially just a binding to Box2D (version 2.3.0 - manual).

For simpler (and more common) use cases, a small number of libraries exist, which are usually more popularly used than love.physics and can be found here: https://github.com/love2d-community/awesome-love2d#physics

Types

Body Bodies are objects with velocity and position.
Contact Contacts are objects created to manage collisions in worlds.
Fixture Fixtures attach shapes to bodies. Added since 0.8.0
Joint Attach multiple bodies together to interact in unique ways.
Shape Shapes are objects used to control mass and collisions.
World A world is an object that contains all bodies and joints.

Functions

love.physics.getDistance Returns the two closest points between two fixtures and their distance. Added since 0.8.0
love.physics.getMeter Returns the meter scale factor. Added since 0.8.0
love.physics.newBody Creates a new body.
love.physics.newChainShape Creates a new ChainShape. Added since 0.8.0
love.physics.newCircleShape Creates a new CircleShape.
love.physics.newDistanceJoint Creates a DistanceJoint between two bodies.
love.physics.newEdgeShape Creates a new EdgeShape. Added since 0.8.0
love.physics.newFixture Creates and attaches a fixture. Added since 0.8.0
love.physics.newFrictionJoint A FrictionJoint applies friction to a body. Added since 0.8.0
love.physics.newGearJoint Create a GearJoint connecting two Joints.
love.physics.newMotorJoint Creates a joint between two bodies which controls the relative motion between them. Added since 0.9.0
love.physics.newMouseJoint Create a joint between a body and the mouse.
love.physics.newPolygonShape Creates a new PolygonShape.
love.physics.newPrismaticJoint Creates a PrismaticJoint between two bodies.
love.physics.newPulleyJoint Creates a PulleyJoint to join two bodies to each other and the ground.
love.physics.newRectangleShape Shorthand for creating rectangular PolygonShapes.
love.physics.newRevoluteJoint Creates a pivot joint between two bodies.
love.physics.newRopeJoint Creates a joint between two bodies that enforces a max distance between them. Added since 0.8.0
love.physics.newWeldJoint A WeldJoint essentially glues two bodies together. Added since 0.8.0
love.physics.newWheelJoint Creates a wheel joint. Added since 0.8.0
love.physics.newWorld Creates a new World.
love.physics.setMeter Sets the meter scale factor. Added since 0.8.0

Enums

BodyType The types of a Body.
JointType Different types of joints.
ShapeType The different types of Shapes, as returned by Shape:getType.

Notes

Box2D's architecture, concepts, and terminologies.

Box2D basic overview.png

See Also



Other Languages