Push and pop array inside array

1 favourites
  • 5 posts
From the Asset Store
Relax and relieve stress by popping bubbles in Fidget Anti- Stress Releaser!
  • I've recently started using Construct 3, and I've noticed that the handling of arrays is a bit different than in other programming languages (at least as far as the event sheet is concerned).

    I would need to insert inside a cell of an array, another array, and then remove it and get the array just removed.

    Using normal JS I would like to recreate this code:

    	myArray = []
    	myArray.push([a, b])
    	var [a,b] = myArray.pop()
    

    Unfortunately, I noticed that Construct only allows you to work on one axis at a time (x or y), and so I can't populate the array with the two new values.

    Same problem for when I want to pop the inserted array.

    Can someone explain me how it works and how I should act in these two cases?

    Tagged:

  • You first push 'a' then on grabbing the index of the new row you pushed you can set at y, 'b' goes to x,1 for example.

  • a construct array can only hold text or numbers

    so you could push a second array as JSON, then convert it back to an array when pop it out

  • The Json object would be a better choice as its arrays inside arrays.

    Although a bit more contrived.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for your responses! :)

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