Can someone tell me why this doesn't work?

Get help using Construct 2

Post » Thu May 30, 2013 4:29 pm

I'm trying to draw a line between points that are created by tapping (or clicking in this case) on the screen but instead of it creating a chain of lines it draws a line between the first point and each other point.

It does this:


Instead of this:


Here's the Event Sheet:


Here you see the "On any Touch Start" and the For loop that SHOULD draw a line between each Route that's placed.

NavPoints is a global variable that starts at -1.

I don't know how common-knowledge it is but if you put a number in parenthesis before .X or .Y it references the specific Instance ID. So Route(NavPoints).X is the X position of whatever instance of Route.
B
6
G
3
Posts: 10
Reputation: 1,121

Post » Thu May 30, 2013 5:58 pm

Looks to me like youre not updating the position of the last route created.
B
48
S
16
G
9
Posts: 1,097
Reputation: 11,195

Post » Thu May 30, 2013 6:15 pm

You have for each route so it will happen for each point from the first, you need a subevent to place the 1st then add to the variable in the loop...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Thu May 30, 2013 6:22 pm

just a thought without going deeply into the problem yet. But after looking at it. I would suggest adding Text.setText = line.count.

As it looks like right now. You create a number of new lines per tick equal to number of Routes. You want to embed the the loop code under the On touch code.

It's ok to track your own points. but you get
navpoint.count that track the numger of objects
loopindex the current count in any loop

however, what I think your doing. Is that your actually drawing a line from
route(navpoint) which is the most recently created object.
route(navpoint+1) which doesn't exist and will be default to 0 so the first one.

you can do
start line at route(navpoint -1)
to route(navpoint)

you can also use
route(route.count - 2)
route(route.count -1)

jayderyu2013-05-30 18:43:46
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Thu May 30, 2013 10:47 pm

Jayderyu was right - I feel really dumb for not seeing it. In attempting to solve an error that kept popping up (explained below) I changed the original formula I had to reading one instance ahead, hence defaulting to zero and creates the behavior you see there.

The error had to do with incorporating the line drawing into the Route placement event - even as a sub-event. It has to be separate.

Regardless! It works now, thank you all for your help! I really appreciate it :)
B
6
G
3
Posts: 10
Reputation: 1,121


Return to How do I....?

Who is online

Users browsing this forum: ChesVCF, engin20020 and 27 guests