How do I a draw line between instances?

Get help using Construct 2

Post » Wed Jan 21, 2015 8:54 pm

Hi all

Cant figure it out.
I have waypoints in my game (instances) and i want to draw a line between them going from first instance to last instance.

Any help is welcome!
Kind Regards.
Savvy001
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Jan 21, 2015 9:08 pm

Global vars for x and y, for each instance, draw a line from current to x and y, set x and y to current, next instance. Kinda like that.

The line would be a sprite you create at current position, rotate towards x and y vars and set length to distance between vars and current position.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Wed Jan 21, 2015 9:11 pm

@ SomeBody

I understand, but the problem is setting the angle and distance to the next instance.
I cant pick them?
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Jan 21, 2015 9:22 pm

Which is why you start with the next instance and then work your way back to the previously set x and y variables. Just add a check to start drawing from second variable onwards.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Wed Jan 21, 2015 9:38 pm

Thanx @Somebody

Its working now.
I made a counter that ads up to the amount of waypoints (looping).
Using that counter i was able to pick the waypoints counting from 0 to the last.
Then i set the distance and angle of the line to the position (also stored in a variable) from the previous picked waypoint.
Now when i erase one waypoint all lines correct themselves automaticly to the new route.
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Wed Jan 21, 2015 9:56 pm

Done with just 2 events & no variable. Just need to adjust image point for line sprite.
You do not have the required permissions to view the files attached to this post.
ImageImage
B
109
S
50
G
23
Posts: 783
Reputation: 22,736

Post » Wed Jan 21, 2015 10:29 pm

@alextro

Wow, thats a good example!
Thank u very much!
B
59
S
21
G
14
Posts: 779
Reputation: 13,927

Post » Thu Jan 22, 2015 7:49 am

@alextro - Wasn't aware of the Self.IID parameter, very elegant.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Thu Jan 22, 2015 6:55 pm

@Somebody
Proven that IID manipulation is rightious way to code ;)
ImageImage
B
109
S
50
G
23
Posts: 783
Reputation: 22,736



Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, maranpis, missile, oosyrag, Yahoo [Bot] and 30 guests