Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to tell which is body A and which is body B upon collision — Gideros Forum

How to tell which is body A and which is body B upon collision

Tom2012Tom2012 Guru
edited April 2013 in General questions
Hi,

My Box2D collision code is full of code like this:
		local fixtureA = event.fixtureA
		local fixtureB = event.fixtureB
		local bodyA = fixtureA:getBody()
		local bodyB = fixtureB:getBody()
 
		if (bodyA.name == "Drag block button" and bodyB.name == "Drag block") then
 
			-- do something
 
		elseif(bodyB.name == "Drag block button" and bodyA.name == "Drag block") then
 
			-- do something
		end
Which doesn't seem like an efficient way to do it.

How do you determine which body is body A and which is body B in a collision?

Thanks

Comments

Sign In or Register to comment.