Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
  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:
C#
local 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})
Posted
Updated 10-May-13 7:32am
v2
Comments
R. Giskard Reventlov 9-May-13 21:25pm    
Try to format the code properly: quite difficult to read as is.

1 solution

You should try asking here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900