Mixin CollisionResolver
CollisionResolver mixin.
Apply to classes to give them callbacks for physics collisions. See World:setCallbacks for more info.
Usage:
local MyClass = class("MyClass")
MyClass:include(PhysicsBody)
MyClass:include(CollisionResolver)
..... -- leaving out physics body creation and stuff
-- print "yay collision" if we collide with another instance of this class
function MyClass:beginContactWith( other, contact, myFixture, otherFixture, selfIsFirst )
if (other:isInstanceOf(MyClass)) then
print("yay collision!")
end
end
Class CollisionResolver
| CollisionResolver:beginContactWith (other, contact, myFixture, otherFixture, selfIsFirst) | Gets called when two fixtures begin to overlap. |
| CollisionResolver:endContactWith (other, contact, myFixture, otherFixture, selfIsFirst) | Gets called when two fixtures cease to overlap. |
| CollisionResolver:preSolveWith (other, contact, myFixture, otherFixture, selfIsFirst) | Gets called before a collision gets resolved. |
| CollisionResolver:postSolveWith (other, contact, myFixture, otherFixture, selfIsFirst) | Gets called after the collision has been resolved. |
Class CollisionResolver
- CollisionResolver:beginContactWith (other, contact, myFixture, otherFixture, selfIsFirst)
-
Gets called when two fixtures begin to overlap.
Parameters:
- other Object object collided with
- contact Contact the Contact object
- myFixture Fixture the Fixture of this object that collided
- otherFixture Fixture the Fixture of the other object that collided
- selfIsFirst bool whether this object was the first objected reported in the collision. Useful for processing collision logic only once in case both objects have a CollisionResolver that was called.
- CollisionResolver:endContactWith (other, contact, myFixture, otherFixture, selfIsFirst)
-
Gets called when two fixtures cease to overlap. This will also be called outside of a world update, when colliding objects are destroyed.
Parameters:
- other Object object collided with
- contact Contact the Contact object
- myFixture Fixture the Fixture of this object that collided
- otherFixture Fixture the Fixture of the other object that collided
- selfIsFirst bool whether this object was the first objected reported in the collision. Useful for processing collision logic only once in case both objects have a CollisionResolver that was called.
- CollisionResolver:preSolveWith (other, contact, myFixture, otherFixture, selfIsFirst)
-
Gets called before a collision gets resolved.
Parameters:
- other Object object collided with
- contact Contact the Contact object
- myFixture Fixture the Fixture of this object that collided
- otherFixture Fixture the Fixture of the other object that collided
- selfIsFirst bool whether this object was the first objected reported in the collision. Useful for processing collision logic only once in case both objects have a CollisionResolver that was called.
- CollisionResolver:postSolveWith (other, contact, myFixture, otherFixture, selfIsFirst)
-
Gets called after the collision has been resolved.
Parameters:
- other Object object collided with
- contact Contact the Contact object
- myFixture Fixture the Fixture of this object that collided
- otherFixture Fixture the Fixture of the other object that collided
- selfIsFirst bool whether this object was the first objected reported in the collision. Useful for processing collision logic only once in case both objects have a CollisionResolver that was called.