How to rotate the green arrow to point the red rectangle when drag ?
local mRound = math.round local mRand = math.random local mCeil = math.ceil local mAtan2 = math.atan2 local mSqrt = math.sqrt local mPi = math.pi local myGroup = display.newGroup() local arrow = display.newRect(100,20,20,50) arrow:setFillColor(0,1,0) local box ={} for i = 1 ,5 do box[i] = {} for j = 1 ,5 do box[i][j] = display.newRect(200,300,50,50) box[i][j].x = i \* 55 box[i][j].y = j\*55 +50 myGroup:insert(box[i][j]) end end box[3][3]:setFillColor(1,0,0) newX = box[3][3].x newY = box[3][3].y function myGroup:touch( event ) if event.phase == "began" then self.markX = self.x self.markY = self.y elseif event.phase == "moved" then local angleBetween = mCeil(mAtan2( (newY- arrow.y), (newX - arrow.x) ) \* 180 / mPi) + 90 arrow.rotation = angleBetween-180 local x = (event.x - event.xStart) + self.markX local y = (event.y - event.yStart) + self.markY self.x, self.y = x, y else end return true end myGroup:addEventListener("touch")