How to make going to previous layout?

  • Hello,

    I'm making a text based game where inventory is in "Inventory" layout.

    When players are reading, they press Inventory button and then game opens Inventory layout. Then I need game to remember that layout where player was when he was pressing Inventory button and open it.

    For example player is in Layout #3 and then he goes to Inventory layout and then when he presses back button, he gets into Layout #3.

    How to make it?

  • You can set a global variable when you push the button inventory.

    Or you can make the inventory on top_layer in each level. With a call function you only need the code once.

  • What I did (Inventory is on same layout, but I did this for a save and load menu) is:

    1) Make a global variable, I called mine last_layout. The variable can either be a number, or text. In my case it's text.

    2) When the player starts the level, make an On Start of Layout and in it make a Set global variable last_layout equal to LayoutName

    There you go! Now all you need to do is:

    3) Have a trigger on the inventory screen so that when a player pressed or clicks it, it does Go to: Layout by name (or number if you used a number) last_layout.

  • I can not do, there is an example that I could download?

  • Put this CAPX together real quick. It's just a simple project with 4 layouts (3 regular layouts and an Inventory layout). The 3 regular layouts share a single event sheet - note: you don't NEED to do this, as they can still have their own sheets and work. Inventory layout has its own inventory sheet.

    "On Start of Layout", as suggested by Equinox80, the layout name is stored in a global variable called Last_Layout. I've made it a text variable, and one easy way to do it would be to simply use the system expression "LayoutName" to automatically set the variable to the name of the current layout.

    In the Inventory Sheet, when the Back button is pressed, I simply use "Go to layout (by name)" and type in the "Last_Layout" variable.

    Remembering Last Layout CAPX

    Hope this is what you're looking for!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks !

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