Here is how to draw a 5px wide line with a touch listener and turn it into a physics object using a rectangle:
require("physics")physics.start() physics.setDrawMode("hybrid") function lengthOf( a, b ) local width, height = b.x-a.x, b.y-a.y return (width\*width + height\*height)^0.5 end local PI = (4\*math.atan(1)) local quickPI = 180 / PI function angleOf( a, b ) return math.atan2( b.y - a.y, b.x - a.x ) \* quickPI end function touch(e) if (e.phase == "began") then local grp = display.newGroup() grp.rect = display.newRect(grp,e.x,e.y,1,1) display.getCurrentStage():setFocus(grp) grp.hasFocus = true grp.start = {x=e.xStart,y=e.yStart} display.getCurrentStage():setFocus(grp) grp:addEventListener("touch",touch) return true elseif (e.target.hasFocus) then local grp = e.target grp.rect:removeSelf() grp.rect = display.newRect( 0, 0, lengthOf( grp.start, e ), 5 ) grp.rect.rotation = angleOf( grp.start, e ) grp.rect.x, grp.rect.y = (grp.start.x+e.x)/2, (grp.start.y+e.y)/2 if (e.phase ~= "moved") then display.getCurrentStage():setFocus(nil) grp.hasFocus = false grp:removeEventListener("touch",touch) physics.addBody(grp.rect,"static") end return true end return false end Runtime:addEventListener("touch",touch)