Hi,
I have two physics bodies that are connected by a Pivot Joint. The joint has been setup to make the two objects move together.Touch Listeners have been added on both objects. When a touch event is received it is being received only on the bottom object and not on the top object. Is there any way to remove both objects linked by a joint when a touch event occurs. I have put the code I am using below:
local orb = display.newImageRect("..\\Images\\orange\_orb.png", 75, 75);
orb:setReferencePoint(display.CenterReferencePoint);
orb.x = mRand(100, \_W-100);
orb.y = mRand(100, \_H-100);
orb.scene = "Orb"
physics.addBody(orb, "dynamic", {bounce = 0.1, friction=5, radius=25});
orb.isBullet = true
local lvlTxt = display.newText("1",0,0,"Helvetica",20)
lvlTxt.x = orb.x
lvlTxt.y = orb.y
physics.addBody(lvlTxt, "dynamic", {bounce = 0.1, friction=5, radius=25});
lvlTxt.scene = "Text"
local myjoint = physics.newJoint( "pivot", orb, lvlTxt, orb.x,orb.y )
playGroup:insert(orb)
playGroup:insert(lvlTxt)
function orb:touch (e)
if (ready == true) then
if (time\_up ~= true) then
if (e.phase == "ended") then
print (e.target.scene)
trackOrbs(self);
end
end
end
--return true;
end
function lvlTxt:touch (e)
if (ready == true) then
if (time\_up ~= true) then
if (e.phase == "ended") then
print (e.target.scene)
trackOrbs(self);
end
end
end
return true;
end
O = O + 1
orb:addEventListener("touch", orb);
lvlTxt:addEventListener("touch", lvlTxt);
[import]uid: 50371 topic_id: 11653 reply_id: 311653[/import]