|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. See notes.
World:setCallbacks( beginContact, endContact, preSolve, postSolve )
- Gets called when two fixtures begin to overlap.
- Gets called when two fixtures cease to overlap. This will also be called outside of a world update, when colliding objects are destroyed.
- Gets called before a collision gets resolved.
- Gets called after the collision has been resolved.
|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.
World:setCallbacks( add, persist, remove, result )
- Called when two shapes first collide.
- Called each frame, if collision lasts more than 1 frame.
- Called when two shapes finish colliding.
- 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.
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, tanget_impulse2) -- do stuff end
Tiếng Việt –