0 Favourites

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

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

  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,159
karshinkoff's avatar
karshinkoff
Unread hot topic
78 10,780
Josek5494's avatar
Josek5494
Unread hot topic
56 4,736
MPPlantOfficial's avatar
MPPlantOfficial