make objects stop when it reach another oject

i am using composer GUI  to make a simple 2 bricks . one of them will be swipes with my touch while the other will be frozen ( static ) , so what i need it when i swipe that brick and it hit the other brick it must stop there .

so what kind of object,physics do i have to chose . i treied so many but nothing made that brick to stop .

i already removed gravity

i am using this code

local pl1 = self:getObjectByName( "pl1" ) pl1.gravityScale=0 local sq1 = self:getObjectByName( "sq1" ) local sq2 = self:getObjectByName( "sq2" ) local sq3 = self:getObjectByName( "sq3" ) local sq4 = self:getObjectByName( "sq4" ) local sq4 = self:getObjectByName( "sq5" ) local sq6 = self:getObjectByName( "sq6" ) local up = self:getObjectByName( "up" ) local down = self:getObjectByName( "down" ) local left = self:getObjectByName( "left" ) local right = self:getObjectByName( "right" ) local bk = self:getObjectByName( "bk" ) local hole = self:getObjectByName( "hole" ) pl1.isMoving = false local LEFT = 300 local CENTER = display.contentCenterX local RIGHT = display.contentWidth - 300 local UpMove = 450 local CENTERY = display.contentCenterY local DownMove = display.contentHeight - 450 local function handleSwipe( event ) if event.phase == "moved" then local dX = event.x - event.xStart local dY = event.y - event.yStart if dX \> 5 then -- swipe right local spot = RIGHT if event.target.x == LEFT then spot = CENTER end transition.to( event.target, {time=3500, x = spot } ) elseif dX \< -5 then -- swipe left local spot = LEFT if event.target.x == RIGHT then spot = CENTER end transition.to( event.target, {time=3500, x = spot } ) end if dY \< -5 then -- swipe left local spoty = DownMove if event.target.y == UpMove then spoty = CENTERY end transition.to( event.target, {time=3500, y = spoty } ) elseif dY \< 5 then -- swipe left local spoty = UpMove if event.target.y == DownMove then spoty = CENTERY end transition.to( event.target, {time=3500, y = spoty } ) end end return true end pl1:addEventListener( "touch", handleSwipe )

and here is the other file with parameters

{"objects":{"id6":{"isSensor":false,"isFixedRotation":false,"isBodyActive":false,"isVisible":true,"imageFile":"images/BoxNormal.png","rotation":0,"x":299,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":false,"linearDamping":100,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-534,"x":552},{"y":534,"x":547},{"y":549,"x":-542},{"y":19,"x":-546},{"y":-532,"x":-539}],"id":"sq2","radius":0,"alpha":1,"strokeWidth":0,"density":0,"friction":0,"bodyType":"static","createdAtStart":true,"isSleepingAllowed":false,"y":43.5,"meta":"id6","tag":"sq2"},"id1":{"targetW":320,"gridW":20,"bgColor":{"b":0.87843137254902,"g":0.72156862745098,"r":0.55294117647059},"gridH":20,"isVisible":true,"children":["id2","id3","id4","id5","id6","id7","id8","id9","id10","id11"],"type":"group","yScale":1,"xScale":1,"yGravity":9.8,"targetH":480,"sceneName":"scene1","gridSnapping":true,"alpha":1,"width":320,"y":0,"x":0,"name":"root","drawMode":"normal","height":480,"meta":"id1","rotation":0,"xGravity":0},"id4":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/BoxNormal.png","rotation":0,"x":164,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":false,"linearDamping":100,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-512,"x":-512},{"y":-512,"x":512},{"y":512,"x":512},{"y":512,"x":-512}],"id":"sq4","radius":0,"alpha":1,"strokeWidth":0,"density":100,"friction":0,"bodyType":"static","createdAtStart":true,"isSleepingAllowed":true,"y":207.5,"meta":"id4","tag":"sq4"},"id3":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/BoxNormal.png","rotation":0,"x":278,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":false,"linearDamping":0,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-512,"x":-512},{"y":-512,"x":512},{"y":512,"x":512},{"y":512,"x":-512}],"id":"sq3","radius":0,"alpha":1,"strokeWidth":0,"density":1,"friction":0,"bodyType":"static","createdAtStart":true,"isSleepingAllowed":true,"y":204.5,"meta":"id3","tag":"sq3"},"id11":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/RedSqureBlue.png","rotation":0,"x":271,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0.2,"physicsEnabled":false,"isBullet":false,"linearDamping":0,"angularDamping":0,"yScale":0.029296875,"xScale":0.029296875,"hasJoint":false,"width":1024,"id":"hole","radius":0,"alpha":1,"strokeWidth":0,"density":1,"friction":0.3,"bodyType":"dynamic","createdAtStart":true,"isSleepingAllowed":true,"y":432.5,"meta":"id11","tag":"hole"},"id10":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/RedSqure.png","rotation":0,"x":164,"yLocked":false,"height":1024,"xLocked":false,"isAwake":false,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":true,"linearDamping":0,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-455,"x":-457},{"y":-457,"x":456},{"y":475,"x":458},{"y":466,"x":-459}],"id":"pl1","radius":0,"alpha":1,"strokeWidth":0,"density":1,"friction":0,"bodyType":"kinematic","createdAtStart":true,"isSleepingAllowed":false,"y":49.5,"meta":"id10","tag":"pl1"},"id9":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/BoxNormal.png","rotation":0,"x":21,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":false,"linearDamping":100,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-512,"x":-512},{"y":-512,"x":512},{"y":512,"x":512},{"y":512,"x":-512}],"id":"sq1","radius":0,"alpha":1,"strokeWidth":0,"density":1,"friction":0,"bodyType":"static","createdAtStart":true,"isSleepingAllowed":false,"y":47.5,"meta":"id9","tag":"sq1"},"id8":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/BoxNormal.png","rotation":0,"x":291,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":false,"linearDamping":0,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-512,"x":-512},{"y":-512,"x":512},{"y":512,"x":512},{"y":512,"x":-512}],"id":"sq5","radius":0,"alpha":1,"strokeWidth":0,"density":1,"friction":0,"bodyType":"static","createdAtStart":true,"isSleepingAllowed":true,"y":307.5,"meta":"id8","tag":"sq5"},"id7":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/BoxNormal.png","rotation":0,"x":42,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0,"physicsEnabled":true,"isBullet":false,"linearDamping":0,"angularDamping":0,"width":1024,"yScale":0.0244140625,"xScale":0.0244140625,"hasJoint":false,"bodyShape":[{"y":-512,"x":-512},{"y":-512,"x":512},{"y":512,"x":512},{"y":512,"x":-512}],"id":"sq6","radius":0,"alpha":1,"strokeWidth":0,"density":1,"friction":0,"bodyType":"static","createdAtStart":true,"isSleepingAllowed":true,"y":318.5,"meta":"id7","tag":"sq6"},"id2":{"isSensor":false,"isFixedRotation":false,"isBodyActive":true,"isVisible":true,"imageFile":"images/bk1.jpg","rotation":0,"x":157,"yLocked":false,"height":1024,"xLocked":false,"isAwake":true,"fillColor":{"a":1,"r":1,"g":1,"b":1},"strokeColor":{"a":1,"r":0.50196078431373,"g":0.50196078431373,"b":0.50196078431373},"bounce":0.2,"physicsEnabled":false,"isBullet":false,"linearDamping":0,"angularDamping":0,"yScale":0.5859375,"xScale":0.21367521584034,"hasJoint":false,"width":1638,"id":"bk","radius":0,"alpha":0.4,"strokeWidth":0,"density":1,"friction":0.3,"bodyType":"dynamic","createdAtStart":true,"isSleepingAllowed":true,"y":254.5,"meta":"id2","tag":"bk"},"id5":{"size":22,"yScale":1,"xScale":1,"type":"text","isVisible":true,"id":"Text","text":"1","alpha":1,"rotation":0,"y":123.5,"font":"native.systemFont","yLocked":false,"createdAtStart":true,"meta":"id5","xLocked":false,"x":723,"textColor":{"r":0,"g":0,"b":0}}},"root":{"object":"id1","numObjects":11},"metadata":{"creator":"Corona Composer","version":"0.6"}}

but

 i cant let that pl1 stop when it reach any other sq1

also the swipes are not in straight path . so i have these 2 things in mind

1- pl1 should stop when it reach the sq1 ( squares )

2- swipes should be only in straight lines

ok now i see that using transition.to is bad with physics . so i am using a new way to do this using the setLinearVelocity and it works fine now

but i have 2 issues now

1- the touch is slow in reposing . i mean i have to swipe my finger so many times to make that object to move

2- when the object hit another brick ( static ) it slightly move up . all parameters for the physics are set to 0 ex: bounce,friction,density, etc

Ok i solved the number 2 which is the slightly move using tweaking in the density and frictions

ok now i see that using transition.to is bad with physics . so i am using a new way to do this using the setLinearVelocity and it works fine now

but i have 2 issues now

1- the touch is slow in reposing . i mean i have to swipe my finger so many times to make that object to move

2- when the object hit another brick ( static ) it slightly move up . all parameters for the physics are set to 0 ex: bounce,friction,density, etc

Ok i solved the number 2 which is the slightly move using tweaking in the density and frictions