try this, it should works perfectly
[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0,0)
local obj1 = display.newRect(0,0,50,50)
physics.addBody(obj1)
obj1.x = 50
obj1:setFillColor(255,0,0)
obj1.name = “obj1”
local obj2 = display.newRect(0,0,30,30)
physics.addBody(obj2)
obj2.y = 80
obj2.name = “obj2”
local obj3 = display.newRect(0,0,60,40)
physics.addBody(obj3)
obj3.x = 150
obj3.name = “obj3”
local function drag(event)
if event.phase == “moved” then
obj1.x = event.x
obj1.y = event.y
end
end
obj1:addEventListener(“touch”, drag)
local function onCollision(self,event)
if event.phase == “began” then
if event.other.name == “obj2” or event.other.name == “obj3” then
print(self.name… " colliding with: "… event.other.name)
end
end
end
obj1.collision = onCollision
obj1:addEventListener(“collision”, obj1)[/lua] [import]uid: 16142 topic_id: 18934 reply_id: 72957[/import]