Quick Array Question about Push

0 favourites
  • 7 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I understand Pop and Push.

    I am having trouble understanding how to choose the bottom Y when trying to change values.

    I have a 2,1,1 Array. It is used to pre-select random numbers to prevent reloading to so the player can't cheat in the game. The game has to currently keep track of two random numbers.

    X0, X1

    What I would like to do is add a Function that will add a row to the bottom and change it.

    I will also have a Function that Pops the top row, I already know how to do this though.

    After adding a row to the bottom how do I then change the bottom row.

    X0, X1

    X0, X1

    Do I have to use a variable to keep track of the bottom row, or is there another way of just changing the bottom row?

    In the Parameters for Push I am not understanding what "Value" means. If I have two values on the axis why is it only asking for one?

  • The bottom of the array index is Array.Width-1.

    Array.Push

    Array.SetAt(Array.Width-1,0) = XXX

    Array.SetAt(Array.Width-1,1) = YYY

  • Thanks I got it.

    Basically the same I do with objects to figure things out like that.

  • While we are on the topic I have another question.

    Is there a difference in using instance variables to store in data over using an Array?

    To me using an array seems like it would be worst because instead of just having the info it has to look for it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It really depends on what you are doing. There's no one answer.

  • To me using an array seems like it would be worst because instead of just having the info it has to look for it.

    But you can´t create some new instance variable in runtime while you can insert new data into an array whenever.

  • If I have an object that has an instance variable then it should have it already. There is no need to create a variable during runtime.

    I suppose if an instance variable won't be interacted with for a long time it is best to use an Array.

    If it will be interacted with often it is better to be a variable.

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