Hello,
I have two specific objects that I need to check if they collide and then execute a function. One is named myIce and the other is myOrange. See the code below:
–mpc graphics
local ice = display.newImage(“2d/babyIce.png”)
ice.xScale = 1
ice.yScale = 1
ice.y = centerY - 120
ice.x = centerX - 210
ice.myName = "myIce"
physics.addBody(ice,“dynamic”,{ density = 100.0, friction = 100, bounce = 0.2 } )
local orangeDrop = display.newImage(“2d/orangeDrop.png”)
orangeDrop.x = centerX + 95
orangeDrop.y = centerY - 55
orangeDrop.name = "myOrange"
So, when myIce and myOrange meet, I want it to start the physics engine and then stop once they stop meeting. Here is that code below:
local function onCollision( event )
if ( event.phase == “began” ) then
print( "began: " … event.object1.myName … " & " … event.object2.myName )
physics.start()
elseif ( event.phase == “ended” ) then
print( "ended: " … event.object1.myName … " & " … event.object2.myName )
physics.stop()
end
end
Runtime:addEventListener( “collision”, onCollision )
Any ideas? Sorry, but I’m from the Unity3d realm but I’m really getting into development with Corona! 