Here you go, I’ve tested this and it works:
local image1 = display.newImageRect("square.png", 50, 50) image1.x, image1.y = 50, 300 local image2 = display.newImageRect("square.png", 50, 50) image2.x, image2.y = 300, 50 --get the angle that the line needs to be rotated to local dx = image1.x - image2.x local dy = image1.y - image2.y local angle = math.deg(math.atan2(dy, dx)) --set how long the line should be local lineLength = math.sqrt((dx \* dx) + (dy \* dy)) --draw the line and rotate it local imageLine = display.newImageRect("line.png", lineLength, 10) imageLine.x, imageLine.y = image2.x + (dx \* 0.5), image2.y + (dy \* 0.5) imageLine.rotation = angle