How can I move a LineObject after creation by line = display.newLine()?
LineObject
line = display.newLine()
resetting line.x and line.y only moves the beginning of the line but I want to move the end as well. LineObject also does not have any .path so I’m not sure what to do.
line.x
line.y
.path
Thanks
Hi, sangihi and Welcome!
1)Try create a new Group 2)Insert LineObject in Group 3)Move Group
Hello. Here’s a little function that does the trick:
function updateLine(line, x2, y2) local temp_parent, temp_x, temp_y = line.parent, line.x, line.y line:removeSelf() line = display.newLine(temp_parent, temp_x, temp_y, x2, y2) end
Example:
local line_test = display.newLine(0, 0, 10, 20) --line starts in 0, 0 / ends in 10, 20 updateLine(line_test, display.contentCenterX, display.contentCenterY) --now line starts in 0, 0 / ends in display.contentCenterX, display.contentCenterY