Loading multiple json files to a single array

0 favourites
  • 10 posts
From the Asset Store
Source code, art assets and music tracks to remake this game
  • Hi everybody,

    I am generating [edit: MANUALLY] levels of my game and store them as json files. After I prepared them all, my goal is to load all information of these levels to an array and use them in game. I have tried this method for first level and it worked. But I can't find the right way to do this for multiple levels. For example I have several json files now but I don't know how to load them all to my array. How can I do that?

    If this explanation is not clear enough please let me know.

    here is the capx

    and here is what my levels will look like

    <img src="https://dl.dropboxusercontent.com/u/87325929/simplePath.png" border="0">

    <img src="https://dl.dropboxusercontent.com/u/87325929/complexPath.png" border="0">

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think your best bet would be to create new instances of the array object, and then load it.

    You can then reference additional arrays by variable or its object(index).

    There are several advantages to using instances such as "for each", and even containers.

  • thank you

    I'll try. But there will be plenty of array instances then. Because i am planning to make hundreds of levels. At least aproximately two hundred. Is that a problem?

    And i didn't understand "There are several advantages to using instances such as "for each", and even containers." part, sorry. Can you explain it a little bit, if you don't mind?

  • You be the judge: link

    Each sprite has an array attached via container.

    I think your only issue would be loading the array... that is if there is a large file to load.

    As for for each. As you can imagine it would work the same as it would for sprites or other objects.

    That is to say picking each of the instances and in a specific order.

  • thanks again newt :)

  • Is it possible to fill these array instances (with different json strings) in one single event or i must use as many events as number of array instances?

    I couldn't figure out how.

  • Well I wouldn't try to download 200 files all at once so your best bet is to create a counter variable, and increase that variable each time a download completes.

    You can use that like dowload "yourfile"&variable&".json".

    Of course you would have to name your json files accordingly.

    Then when one download completes add to the variable.

  • thank you so much great help.

    edit: Sorry, i misunderstood. Don't I try to upload (and fill the arrays), instead of download? I already can download the files manually, but can't upload them.

  • Ok, um ....lets call it import.

  • Finally I found this tutorial :D

    awesome tutorial

    and thank you too

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