Difference between revisions of "World:setCallbacks"

(Added note about Result callback, see Box2D documentation for reference.)
m (Fixed typo with LOVE)
Line 17: Line 17:
 
{{param|function|persist|Called each frame, if collision lasts more than 1 frame.}}
 
{{param|function|persist|Called each frame, if collision lasts more than 1 frame.}}
 
{{param|function|remove|Called when two shapes finish colliding.}}
 
{{param|function|remove|Called when two shapes finish colliding.}}
{{param|function|result|Called after a collision has been calculated. Note: This callback is not properly bound in Love2D at the time of writing, as a result, this callback does not get called, nor do proper arguments get passed for it.}}
+
{{param|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 ===
 
=== Returns ===
 
Nothing.
 
Nothing.

Revision as of 01:01, 18 October 2011

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