Checking collisions on each edge?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
DelishusCake
Prole
Posts: 8
Joined: Sat Mar 10, 2012 8:31 pm

Checking collisions on each edge?

Post 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?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Checking collisions on each edge?

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests