It looks like you're new here. If you want to get involved, click one of these buttons!
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 |
Comments
For example, i make sure that "Drag block" is at B, so if i found "Drag block" at A, then i do something like.
local temp = bodyA
bodyA = bodyB
bodyB = temp
Likes: hgvyas123
@hgvyas123 - glad to know I'm not the only one doing that. It hasn't caused any performance issues I can see in my game so probably keep doing it.
I'm still curious about Box2D though... If you have two bodies moving towards each other, how does the engine determine which is A and B?
if body.parent==ego
so ego.body.parent==ego. That way I can test directly against the name of the sprite in the source code rather than having to introduce a "name" string. Saves typing!
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
bodyA,bodyB = bodyB,bodyA
Someone can correct me if not
Likes: tkhnoman, hgvyas123, Tom2012
http://BlueBilby.com/
Likes: WauloK
Likes: WauloK
Likes: WauloK
The code below doesn't work -
local temp = bodyA
bodyA = bodyB
bodyB = temp
and it can not be use for compare
Likes: fxone