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

Get help using Construct 2

Post » Sun Jul 24, 2016 5:40 pm

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?
B
9
S
2
Posts: 4
Reputation: 533

Post » Sun Jul 24, 2016 6:06 pm

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).
ImageImageImage
B
71
S
22
G
248
Posts: 3,758
Reputation: 138,067


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 22 guests