Array: I am missing something

Discussion and feedback on Construct 2

Post » Tue Nov 12, 2013 6:55 pm

I am trying to work with an array. I want a 1-dimensional array and I push the items into it.

I created an array object called msgArray and configured it with:
width: 0
height: 0
depth: 0

on a button press I push two separate values "roll" and "2" in the x-axis.

If I display msgArray.asJSON in a text field it gives me a valid string with two empty cells in the "data" part :/

"{"c2array":true,"size":[2,0,0],"data":[[],[]]}"

IF I initialize the array with width: 1, height: 1, and depth: 1 everything works as expected, but wastes plenty of space due to the added dimensions.

I'm guessing, that I am doing something wrong as I can't imagine that we would be forced to have a 3-D array

Thanks for any assistancecangelodawg2013-11-12 18:56:06
B
18
S
6
G
2
Posts: 27
Reputation: 2,945

Post » Tue Nov 12, 2013 7:01 pm

width: 0
height: 1
depth: 1

Arrays in C2 are wonky. For even a 1D array in C2.
Width represents number of Objects. So you have 0. No objects to start with.

Height/Depth. However you still need the SPOT in the object to actually sore the data. So even a 1D array still needs to define H/D with a 1.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Tue Nov 12, 2013 7:45 pm

thanks for the reply...that creates plenty of waste for my needs. I'm just sending simple info via a socket to a node.js app...it looks like my case is better off creating a simple message string with custom delimiter. Was trying to short cut that with something more standard
B
18
S
6
G
2
Posts: 27
Reputation: 2,945


Return to Construct 2 General

Who is online

Users browsing this forum: cangelodawg and 6 guests