[Resolved] How i can create a line between 2 points

i am new on corona and i create 2 points with random, and i want to know how i can display a line:
start on 1 and end on the 2… help please [import]uid: 138440 topic_id: 25654 reply_id: 325654[/import]

Hi Rasecleibot,

Try running this code;
[lua]math.randomseed(os.time())

x1, y1 = math.random(1,320), math.random(1,480)
x2, y2 = math.random(1,320), math.random(1,480)

local myLine = display.newLine(x1,y1, x2,y2)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 25654 reply_id: 103681[/import]

it works thank you…
what this do :math.randomseed(os.time())

And if i have like 2 points(a,b);
a.x = 400; a.y = 400;
b.x = 700; b.y = 100;
How i can draw the line :slight_smile: maybe the code above do it but i really don’t understand how it do it… help please and [import]uid: 138440 topic_id: 25654 reply_id: 103795[/import]

That line makes math.random random based on the time. (If you don’t use math.randomseed it will not be truly random.)

You don’t need it if you aren’t using math.radom.

For your question;

[lua]aX = 400
aY = 400
bX = 700
bY = 100

local myLine = display.newLine(aX,aY, bX,bY)[/lua]

Or;

[lua]aX, aY = 400, 400
bX, bY = 700, 100

local myLine = display.newLine(aX,aY, bX,bY)[/lua]

(Which is the same but a little neater.)

Peach :slight_smile: [import]uid: 52491 topic_id: 25654 reply_id: 103820[/import]

Thank you so much it works perfectly :slight_smile: and also thanks for explain me, you are awesome. [import]uid: 138440 topic_id: 25654 reply_id: 103909[/import]

No worries, always happy to help :slight_smile:

(Marked as resolved.)

Peach [import]uid: 52491 topic_id: 25654 reply_id: 103974[/import]