Hi, in my game i have created a collision function, in this game multiple eggs fall from the sky and when they collide with the “ground” i want them to disappear … the problem is that when the first contacts the ground it disappears but the rest of them don’t… can you pls help me?
COLLISON CODE:
function onGroundCollision( self, event )
if ( event.phase == “began” ) then
if(self.myName == “egg”) then
if(event.other.myName == “ground”) then
audio.play(sound3)
self.isVisible = false
self:removeSelf()
end
end
end
end
FRAMES CODE:
this is the code that drops multiple eggs
ocal function onFrame(event)
frameCounter = frameCounter + 1
if(frameCounter % 40 == 0 and eggCount > 0) then
eggCount = eggCount - 1
local egg = display.newImage(“egg.png”)
egg.x = math.random(0, 310)
egg.y = 0
egg.rotation = math.random(0, 360)
physics.addBody(egg, {density = 2.0, friction = 1.5, bounce=0.01})
