Array Editor Backwards?

Post » Tue May 16, 2017 1:25 pm

Using the new data editor for arrays I always had in my head that X was the row and Y the column. And that's how it shows up in the Debugger.

But it seems that the X is left to right and the Y is up and down in the new editor. I guess it's not a huge deal, it just seems like it should be the other way around. I can't remember how the C2 data editor worked. Maybe it worked the same way and I just made some hack so that it would make sense in my head.
B
19
S
8
Posts: 15
Reputation: 1,405

Post » Tue May 16, 2017 1:28 pm

I think it's always been like that.

X - is usually left to right. (horizontal)
Y - vertical.
Z - depth.

I know sometimes if just feels wrong i don't know why. :p
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,060
Reputation: 14,054

Post » Tue May 16, 2017 3:21 pm

Column major / row major can be pretty confusing, when I was developing the array editor I actually had it the wrong way round for several months. During the alpha @Kyatric noticed it was flipping the data around each time you saved and re-opened a file. It should match how the runtime actually reads the files currently.

I guess if it gives you real headaches then you could create a feature request for a "invert array editor" setting? Can see how much traction it gets :P
Scirra Employee
B
6
S
2
Posts: 135
Reputation: 928

Post » Tue May 16, 2017 4:28 pm

Well it is actually based on maths (in an orthonormal plan X is horizontal and Y vertical).
Image

It is actually how coordinates work in the layout view as well (where the origin point is actually top left and the Y axis actually goes "down").
Image

The C2 data editor is a third-part application, there is no actual editor for C2, but according to the video example in the store, columns are used in a spreadsheet way. I haven't been able to see so far how it actually translates once in JSON imported in Construct. But you would have each X representing an actual column, and then each Y being an "index".

I would argue though that "spreadsheet" way makes more sense for humans to read.
The issue then being, you would have to "twist" the position in your mind/events when you are actually reaching for the coordinates in code.

For example, and still according to the example video, at 2:15 for example as it is being displayed:
X (horizontal)
0 = ID, 1 = Name, 2 = Value, 3 = Modifier

Then the Y (vertical, each rows)
Y 0 = skipped, used to name the columns
Array.At(1,2) = Wand +2 (Name of ID 1)
Array.At(3,5) = 4 (Modifier of ID 4)

In a logical way, you would tend to use X as ID, and for each ID have then 3 Y (Name, Value, Modifier) you can relate to.

X> ---------------- 0 ---------------- 1 ---------------- 2 ---------------- 3 ---------------- 4...
Yv
Name ------ Wand +1 ------ Wand +2 ------ Wand + 3 --- Wand +4 --- Wand + 5 ...
Value ----------- 1 ---------------- 2 ---------------- 3 ---------------- 4 ---------------- 5...
Modifier ------- 1 ---------------- 2 ---------------- 3 ---------------- 4 ---------------- 5...

In this setting :
Array.At(1,0) = Wand + 2 (Name of ID 1)
Array.At(3,2) = 4 (Modifier of ID 3) (which is the fourth entry because arrays are 0 based)

Less "readable", but true to logic.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,332
Reputation: 71,306

Post » Tue May 16, 2017 5:00 pm

I've spent the past 2 weeks making my own Array Editor. Maybe worth releasing/sharing?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 991
Reputation: 11,231

Post » Wed May 17, 2017 5:17 am

I would definitely be interested.
B
19
S
8
Posts: 15
Reputation: 1,405

Post » Wed May 17, 2017 12:16 pm

The way we were taught in school was X is like a cross symbol (across), and Y is like an arrow symbol pointing down (up and down).
B
43
S
23
G
21
Posts: 735
Reputation: 12,132

Post » Wed May 17, 2017 12:53 pm

Certainly I'd always choose x horizontal and y as vertical when making a table. It's the standard for 2D space after all, so long as your not talking about kinematics which uses i and j instead.

I was more commenting on the fact that internally in construct the JSON data is stored as columns which is nice and logical for reading a cell.

| | | | | | X
| | | | | |
| | | | | |
| | | | | |
Y


Code: Select all
var cell = obj[x][y];


However, typically table data is stored as rows, as it makes it easier to insert new rows. When you're using rows getting the entry for a cell in that format is the opposite way around.
___________
___________ X
___________
___________
___________
Y


Code: Select all
var cell = obj[y][x];
Scirra Employee
B
6
S
2
Posts: 135
Reputation: 928


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest