Difference between revisions of "World:setCallbacks"

m (Remove superfluous description from old variant)
(Move annotation to hopefully interact with the picker better)
Line 1: Line 1:
{{newin|[[0.8.0]]|080|type=method}}
 
 
Sets functions for the collision callbacks during the world update.
 
Sets functions for the collision callbacks during the world update.
  
Line 8: Line 7:
 
If you are interested to know when exactly each callback is called, consult a Box2d [http://www.iforce2d.net/b2dtut/collision-anatomy manual]
 
If you are interested to know when exactly each callback is called, consult a Box2d [http://www.iforce2d.net/b2dtut/collision-anatomy manual]
 
== Function ==
 
== Function ==
 +
{{newin|[[0.8.0]]|080|type=method}}
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 21: Line 21:
  
 
<br /><br />
 
<br /><br />
{{oldin|[[0.8.0]]|080|type=variant}}
 
 
== Function ==
 
== Function ==
 +
{{oldin|[[0.8.0]]|080|type=variant}}
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">

Revision as of 21:22, 9 April 2016

Sets functions for the collision callbacks during the world update.

Four Lua functions can be given as arguments. The value nil removes a function.

When called, each function will be passed three arguments. The first two arguments are the colliding fixtures and the third argument is the Contact between them. The postSolve callback additionally gets the normal and tangent impulse for each contact point. See notes.

If you are interested to know when exactly each callback is called, consult a Box2d manual

Function

Available since LÖVE 0.8.0
This method is not supported in earlier versions.

Synopsis

World:setCallbacks( beginContact, endContact, preSolve, postSolve )

Arguments

function beginContact
Gets called when two fixtures begin to overlap.
function endContact
Gets called when two fixtures cease to overlap. This will also be called outside of a world update, when colliding objects are destroyed.
function preSolve
Gets called before a collision gets resolved.
function postSolve
Gets called after the collision has been resolved.

Returns

Nothing.



Function

Removed in LÖVE 0.8.0
This variant is not supported in that and later versions.

Synopsis

World:setCallbacks( add, persist, remove, result )

Arguments

function add
Called when two shapes first collide.
function persist
Called each frame, if collision lasts more than 1 frame.
function remove
Called when two shapes finish colliding.
function result
Called after a collision has been calculated. Note: This callback is not properly bound in LOVE at the time of writing, as a result, this callback does not get called, nor do proper arguments get passed for it.

Returns

Nothing.

Notes

Below are the parameters for the postSolve callback. Note that the numbers of normal and tangent impulse correspond with the numbers of contact points.

function postSolve(fixture1, fixture2, contact, normal_impulse1, tangent_impulse1, normal_impulse2, tangent_impulse2)
-- do stuff
end

See Also


Other Languages