Hi
I’m newbies for corona engine,
I’ve problem about collision event,
As code below, if I need to move an object crate1 with event “touch” against an object crate2.
When I move crate1 with touch event against crate2, why The debugger not show message in print function?
I try it doesn’t work, Who can help me?
Thanks in advance
Mate
[code]
local physics = require( “physics” )
physics.start()
local crate1 = display.newImage( “crate.png” )
crate1.x = 180; crate1.y = 100
crate1.myName = “first crate”
local crate2 = display.newImage( “crate.png” )
crate2.x = 180; crate2.y = 200
crate2.myName = “second crate”
physics.addBody( crate1,“kinematic”, {isSensor = true, density=3.0, friction=0.5, bounce=0.3 } )
physics.addBody( crate2,“kinematic”, { isSensor = true,density=3.0, friction=0.5, bounce=0.3 } )
local function onLocalCollision( self, event )
if ( event.phase == “began” ) then
print( self.myName … ": collision began with " … event.other.myName )
elseif ( event.phase == “ended” ) then
print( self.myName … ": collision ended with " … event.other.myName )
end
end
local function move(e)
if e.phase == “moved” then
crate1.x = e.x
crate1.y=e.y
end
end
crate1.collision = onLocalCollision
crate1:addEventListener( “collision”, crate1 )
crate1:addEventListener( “touch”, move )
crate2.collision = onLocalCollision
crate2:addEventListener( “collision”, crate2 )
[/code] [import]uid: 58733 topic_id: 11969 reply_id: 311969[/import]
