Display.newLine

Hi,

Is it possible to reassign coordinates of a line later ?

myLine=display.newLine(10,10,20,20)

Something like:

myLine.x1=20

myLine.y1=20

myLine.x2=40

myLine.y2=40

Thank you.

YourLineObject:append() ?

Look for it in the docs page. I think it’s what you are after :wink:

Edit: i misread your post, if you are looking to do what Ed asks below, then my advice is not correct.

@Shadrak,

Are you saying, you want to change the vertices of the line after you make it?

If so, then I’m pretty sure the answer is, “No.”  I generally solve this by removing the existing line and re-drawing it.

-Ed

Thank you for your answer, the solution also seems to me by removing the existing line and re-drawing it.

I haven’t tried it , but couldn’t you do it with scaling ? 

So if you had a line that with scale 1,1 and anchor 0,0 went from 0,0 to 1,1 and scaled it by x,y wouldn’t the end point end up at x,y ? then you could move it to move the origin ?

Some HTML stuff draws lines like this - works with a stock line graphic and stretches it and flips it till it is in the right place.

Really depends on efficiency. It obviously introduces a scale into every line rendering but would stop garbage collection deletion problems maybe ?

It’s probably just as efficient to remove/recreate than it is to change the points anyway.

Rob

Might depend on what you were doing with them :) 

YourLineObject:append() ?

Look for it in the docs page. I think it’s what you are after :wink:

Edit: i misread your post, if you are looking to do what Ed asks below, then my advice is not correct.

@Shadrak,

Are you saying, you want to change the vertices of the line after you make it?

If so, then I’m pretty sure the answer is, “No.”  I generally solve this by removing the existing line and re-drawing it.

-Ed

Thank you for your answer, the solution also seems to me by removing the existing line and re-drawing it.

I haven’t tried it , but couldn’t you do it with scaling ? 

So if you had a line that with scale 1,1 and anchor 0,0 went from 0,0 to 1,1 and scaled it by x,y wouldn’t the end point end up at x,y ? then you could move it to move the origin ?

Some HTML stuff draws lines like this - works with a stock line graphic and stretches it and flips it till it is in the right place.

Really depends on efficiency. It obviously introduces a scale into every line rendering but would stop garbage collection deletion problems maybe ?

It’s probably just as efficient to remove/recreate than it is to change the points anyway.

Rob

Might depend on what you were doing with them :)