local cir = display.newCircle(170,200,40) cir:setFillColor(0.4,0.5,0.6) local function cueShot( event ) local t = event.target local phase = event.phase if "began" == phase then display.getCurrentStage():setFocus( t ) t.isFocus = true event.target.x = t.x event.target.y = t.y myLine = nil elseif t.isFocus then if "moved" == phase then if ( myLine ) then myLine.parent:remove( myLine ) -- erase previous line, if any end myLine = display.newLine( t.x,t.y, event.x,event.y ) myLine:setStrokeColor( 1, 1, 1,0.5) myLine.strokeWidth = 30 elseif "ended" == phase or "cancelled" == phase then display.getCurrentStage():setFocus( nil ) t.isFocus = false if ( myLine ) then myLine.parent:remove( myLine ) end end end return true -- Stop further propagation of touch event end cir:addEventListener("touch",cueShot)
How to draw a line from the circle by dragging the screen ?