Can someone tell me why this doesn't work?

0 favourites
  • 5 posts
  • 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:

    <img src="http://i.imgur.com/WZuR3Wwl.jpg" border="0" />

    Instead of this:

    <img src="http://i.imgur.com/xaKDkZ8l.jpg" border="0" />

    Here's the Event Sheet:

    <img src="http://i.imgur.com/L2oL125.jpg" border="0" />

    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.

  • Looks to me like youre not updating the position of the last route created.

  • 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...

  • 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)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)