here is an example that you could test at home
i would in effect scale a line according to the position of event and orientate the line according to the event.
the problem i when i add these line, my function getAngle don’t work properly…could you tell me why
line.yScale=event.y-cy
the snippet :
--main.lua local player={} player.body=display.newCircle(200,200,10) line=display.newRect(50,50,2,2) --line who the begin is the player and the end is the event line:setFillColor(1,1,1) line.anchorY=1 function playerInMovement() xposMov=math.random(0,400) yposMov=math.random(0,400) transition.to(player.body, {time=900,x=xposMov,y=yposMov}) transition.to(player.body, {delay=900,time=400,x=50,y=50}) end timer.performWithDelay(1800,playerInMovement,-1) function getAngle(x1,y1,x2,y2) local Angle= math.atan2(y2 - y1, x2 - x1) return math.deg(Angle) end Runtime:addEventListener("touch",function(event) if event.phase == "began" then elseif event.phase == "moved" then local cx, cy = player.body:localToContent(0, 0) line.x=cx line.y=cy line.yScale=event.y-cy local angle = getAngle(cx,cy,event.x,event.y) line.rotation = angle+90 elseif event.phase == "ended" then end end)