Difference between revisions of "World:setCallbacks"

m (Fixed typo with LOVE)
(Added 0.8.0 method.)
Line 1: Line 1:
 +
{{newin|[[0.8.0]]|type=method}}
 +
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.
 +
== Function ==
 +
=== Synopsis ===
 +
<source lang="lua">
 +
World:setCallbacks( beginContact, endContact, preSolve, postSolve )
 +
</source>
 +
=== Arguments ===
 +
{{param|function|beginContact|Gets called when two fixtures begin to overlap.}}
 +
{{param|function|endContact|Gets called when two fixtures cease to overlap.}}
 +
{{param|function|preSolve|Gets called before a collision gets resolved.}}
 +
{{param|function|postSolve|Gets called after the collision has been resolved.}}
 +
=== Returns ===
 +
Nothing.
 +
 +
<br /><br />
 +
{{oldin|[[0.8.0]]|type=method}}
 
Set functions to be called when shapes collide.  
 
Set functions to be called when shapes collide.  
  

Revision as of 06:21, 17 April 2012

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

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.

Function

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.
function preSolve
Gets called before a collision gets resolved.
function postSolve
Gets called after the collision has been resolved.

Returns

Nothing.



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

Set functions to be called when shapes collide.

Four Lua functions can be given as arguments. The value nil can be given for events that are uninteresting.


When called, each function will be passed three arguments. The first two arguments (one for each shape) will pass data that has been set with Shape:setData (or nil). The third argument passes the Contact between the two shapes.

Note: Using Shape:destroy when there is an active remove callback can lead to a crash. It is possible to work around this issue by only destroying object that are not in active contact with anything.

Function

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.

See Also


Other Languages