I have a series of round objects defined as follows:
local myBalloon = display.newImageRect("images/cracker.png", 20, 20);
myBalloon:setReferencePoint(display.CenterReferencePoint);
myBalloon.x = Random(50, _W-50);
myBalloon.y = (-10);
myBalloon.myName="balloon"
myBalloon.isSleepingAllowed = false;
physics.addBody(myBalloon, "dynamic", {density=3.0, friction=1.0, bounce=0.0, radius=9});
I then have a single moveable oject defined as such:
local threeWay = display.newImageRect("images/3way.png", 80, 43);
threeWay:setReferencePoint(display.CenterReferencePoint);
threeWay.x = (display.contentWidth / 2);
threeWay.y = (display.contentHeight -15);
threeWay.myName = "threeway"
pentagonShape = { -40,-5, 0,-22, 40,-5, 35,20, -35,20 }
physics.addBody(threeWay, "static", {density=4.0, friction=1.7, bounce=0.0, shape=pentagonShape});
I also have collision detection set up for the round objects like so:
function myBalloon:collision(e)
if (timeLeft ~= false) then
if (playerReady == true) then
if (e.phase == "ended") then
if ( e.other.myName == "threeway" ) then
audio.play(balloonPop);
removeBalloons(self);
end
end
end
end
end
The collision work for the most part, but sometimes the round objects will land on the moveable objects and roll down for a little bit before being taken care of by the collision detection.
How do I provide a more instantaneous effect for the collision? Do the attributes of the objects need to be different so there is more "force" on the collision?
Put "isSensor" as "true" on the baloon, this way it will trigger your collision function without bumping, rolling, etc...
:)