How do I Switch Between Layouts Properly

0 favourites
  • 3 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • Hi, I've just created a title screen layout, and I also have a layout for Room1. I've got it to go to Room1 and start the game when I click on the "Start" button from the Title Screen layout. Now, when the game switches to a new layout, shouldn't everything disappear from the previous layout? I'm still seeing the title screen objects when I'm running the Room1 layout (and vice versa). I've got it set up so that if I hit the 'Esc' button while in Room1, it saves the game, then, on save, it goes to the title screen layout where the options are, and then I can return to the game. Is there some steps missing?

    As a separate question, I've also made all the objects in the game global. Is there a reason to have non-global objects?

    Thanks

  • Well, on experimenting, I switched the menu objects in the title screen layout to non-global and that seems to have fixed the problem. I'm still curious about what will happen when I make future "Rooms". Do I need to make the objects in the main game, like the characters and smashable tables, non-global as well? I want to be able to return to a room and see the dead bodies and broken objects still lying around, but I don't want to see objects from multiple layouts at the same time. I'll try the persist behavior for those things.

    Maybe the global objects should just be limited to the HUD/GUI objects?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • By default most visual objects in layouts are non-global.

    As such, when you move from a layout to another, all the non-global instances are destroyed. Global object just means that moving from a layout to another, the instance is not destroyed and stays on screen (which is not what you are trying to achieve).

    If you are looking to have access to your menu even when ingame, you can look into making it a global layer.

    To have "persistent" rooms, you have several ways to do so.

    a/ Each room layout is a different layout in your game. As such, use the persist behavior for your objects.

    b/ Each room is drawn on the same layout, you dynamically load/save/keep the current states of the room in some data structure (array likely).

    A bit more difficult, needs a lot of organisation, you need, when leaving a room to keep somehow in memory the position/state/all useful infos in relation to the objects on screen. And you need when entering the room (likely the condition "On start of layout" or a function of your choice) to first destroy everything, and then place the correct instances in the correct positions/states you saved them in.

    It's doable, it just require more events work on your side and a careful organisation/data structure/planning of what and how to keep it in memory.

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