Array: I am missing something

0 favourites
  • 3 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • 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 assistance

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

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