Arrays, push/insert on 2D array.

From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I seem to have developed some kind of array dyslexia. I've worked with arrays plenty in the past but for some reason it's not working as I'm expecting in C3.

    Let's say that I have a 2D array and I want to add a new row to it, let's say it's just 2 elements 'wide'

    Do I push twice onto X, onto Y, or insert?

    Everything I try, I seem to get very strange results. I have a loop where I'm trying to add a bunch of new rows, but it all seems to get tagged endlessly onto one row, or the next row seems to inherit the previous row etc.

    Basically, say I'm trying to add a new row, say .at(row,0) and .at(row,1), how do I push/insert them?

  • I usually do this:

    Array Push Back value v1 on X axis
    Array set value at (self.width-1, 1) to v2
    Array set value at (self.width-1, 2) to v3
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks. Ok, I think I see where I was getting confused. I didn't realise that 'Push' with a value of, say 1, filled the entire row with 1's. That's fine I guess, I can push 0's and then fill it manually.

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