How do I use different arrays for different layouts?

0 favourites
  • 4 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I've created a universal event sheet that can interpret the data I put in my json arrays to make a room like so:

    My goal is to create an event sheet and a json string for every one of my layouts.

    When I go into the event sheet for the first layout and call the json file using this simple function, it works:

    However, when I try to go to the 2nd layout, with the exact same code, not only does it not load my array, but when I try to go back to my first room it isn't loaded either.

    This is how the first level looks like and how every level should look like: (purpleBlock: Player & green block: teleporter to 2nd layout). Side note: The border of each room is calculated separately, it is not written in the json array.

    This is how the 2nd layout looks no matter what I do:

    And, as I said above, if I go back to the 1st layout, it is empty.

    This is a very complicated issue that has been bugging me the whole day and I can't continue to work on anything before I fix it.

    If it's not too much to ask, I'd like to share my code with someone directly because I have a very hard time describing everything going on in my code. I'm sorry in advance if I am hard to work with, I just bought Construct 3 a couple of days ago.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hiya, if you are using this method then I don't think you need multiple layouts? You should be able to use one layout and load the different files into the one array on request. The problem you encountered, maybe the event sheets are not linked to the layouts correctly? This is a common cause of not running the events as expected. Also I see your event is running an array called Rooms but you load the data into arrays called RG so that's confusing.

  • lionz Thanks a lot for replying! I choose to use one layout for each level is because I don't know if it's possible, when I end a level, to go to the 2nd one if it's on the same layout.

    My idea was that each level has its own layout and json, so that it can generate more easily the blocks in every scene, especially the border and empty spaces.

    I know my code is confusing, I'm sorry, but "Rooms" is a family where I put all my arrays, and RG_1 and RG_2 are the 2 arrays I have there right now. I also named my json files the exact same way (RG_1.json and RG_2.json). I wanted to give all my arrays the property to read 1 and 2 the way I showed you in the first picture.

    Do you have any suggestions as to how to use a single layout? Instead of a different json for each layout, would using the Z dimension work? Any further help is greatly appreciated, and thank you in advanced for trying to help :)!

  • The use of families looks like it is the reason it's not working, you are not specifying which array to grab the data from when you use a family. If you want to do it per layout then you should run that logic through the specific array that has the data.

    The way to do it with one layout is to keep refilling the one array with the data from the correct level file. So what you're doing for level 1, you call it again from level 2. The way to change the data in the array could be to set a global variable for level number then restart the layout, if level=1 then grab from json1 and if level = 2 then from json2 etc.

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