How do I successfully push X and Y values onto an array?

0 favourites
  • 2 posts
From the Asset Store
Push the Box Puzzle Game
$10.80 USD
10% off
Push the Box Puzzle Game likes Sokoban made with Illustrator
  • I've quite a bit of programming experience but having a real mental block when it comes to arrays in Construct 2.

    I have two values from a coordinate on screen - an X and Y where the user clicked. I want to store them in an 5-1-1 array.

    My thought is to front push an X value and then a Y value but that doesn't provide the expected results. After 1 click this is what I have:

    Element Data

    0 700, 1200

    1 700, 0

    2 700, 0

    3 700, 0

    4 700, 0

    5 700, 0

    I'm really confused because I would expect that I have one element with the first two values and that is is. If I click again I get:

    0 700,1200,1200

    1 700,700,1200

    2 700,700,0

    3 700,700,0

    4 700,700,0

    5 700,700,0

    I think I understand what is happening however I can't use this method for storing waypoints in an array. Should I have two separate arrays an X and Y or use a different method (insert / set at) to set the values?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can push X, but then you have to set Y explicitly, at the newly pushed index (0 if pushing from the front, or Width-1 if from the bottom).

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