Detecting collision object to appear on another.

Hi,

I have a doll that appears and disappears (no transition) around the screen, but when it appears on another image I found. 

I tried with:

local physics = require (“physics”)

physics.start()

Both items addBody Statics 

function functionx (e)

       if (e.phase == “began”) then

             print (“Collision ok”);

       end

end

Runtime:addEventListener(“collision”, functionx)

Thanks.

what happen?

local physics = require( "physics" ); physics.start(); physics.setDrawMode("hybrid"); \_W = display.contentWidth; \_H = display.contentHeight; function one() local obj1 = display.newRect ( 160 , 240, 100, 100); obj1:setFillColor(1,1,0); physics.addBody(obj1, "static"); end function two() local obj2 = display.newRect ( 150 , 250, 100, 100); obj2:setFillColor(1,0,0); physics.addBody(obj2, "static"); end local function onCollision( event )     if ( event.phase == "began" ) then         print( "Collision" );     end end timer.performWithDelay(500, one, 1) timer.performWithDelay(100, two, 1) Runtime:addEventListener( "collision", onCollision )

Static bodies only collide with dynamic bodies - they won’t collide with other static bodies.

Unable to detect two objects on each other without letting it could not move, because the physical moved, I solved if the two objects are visible at the same time in the same place. 

Thank equally as well have understood physics better.

what happen?

local physics = require( "physics" ); physics.start(); physics.setDrawMode("hybrid"); \_W = display.contentWidth; \_H = display.contentHeight; function one() local obj1 = display.newRect ( 160 , 240, 100, 100); obj1:setFillColor(1,1,0); physics.addBody(obj1, "static"); end function two() local obj2 = display.newRect ( 150 , 250, 100, 100); obj2:setFillColor(1,0,0); physics.addBody(obj2, "static"); end local function onCollision( event )     if ( event.phase == "began" ) then         print( "Collision" );     end end timer.performWithDelay(500, one, 1) timer.performWithDelay(100, two, 1) Runtime:addEventListener( "collision", onCollision )

Static bodies only collide with dynamic bodies - they won’t collide with other static bodies.

Unable to detect two objects on each other without letting it could not move, because the physical moved, I solved if the two objects are visible at the same time in the same place. 

Thank equally as well have understood physics better.