Page 1 of 1

Checking collisions on each edge?

Posted: Tue May 01, 2012 6:23 pm
by DelishusCake
Increasingly, I'm finding that the physics module does not follow box2d as closely as it claims :( . For instance, in a platformer with Box2Djs, I could check if the player is on the floor using:

Code: Select all

player.onFloor = function()
	{
		var edge;
		for (edge = this.body.GetContactList(); edge != null; edge = edge.next) 
		{
			var a = new b2WorldManifold();
			edge.contact.GetWorldManifold(a);
			if(edge.contact.IsTouching() && a.m_normal.y > 0.7)
			{
				if(edge.contact.GetFixtureA().GetUserData().type == "player") 
					return true;
			}
		};
		return false;
	};
But the physics module has neither contact lists nor world manifolds, so I have no idea how to do this in love2d. Could anyone help me?

Re: Checking collisions on each edge?

Posted: Tue May 01, 2012 6:57 pm
by Robin
See World:getContactList and World:setCallbacks. I don't know what WorldManifolds are, but usually, collision callbacks are used for that kind of thing when using love.physics.