How do I properly restart a layout?

  • Hi

    Ok, this is something I've been struggling with since I switched to Construct from Clickteam Fusion more than a year ago; How do I restart a layout so that all the objects return to their initial position/visibility/initial values etc? Whenever I try, for example, the restart layout event things that had become visible started as visible.

    And on the same note, is there a way to make event sheets not be global? I is super annoying not being able to just copy event folders from one layout to another while keeping the name. And in relation to the above question, how do I return a event sheet to it's original status?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dude what condition are you using before the >System>Restart layout

    If you use like Button is on click>SYstem:Restart layout that might be something else

  • Providing a capx can help us better understand what you need.

  • I mean, just any capx, doesn't really matter. What I mean is, is there a setting or something to make objects and layouts reset after the layout ends?

  • In general it does work. Try the built-in Platform template. When the player falls off the screen, the layout restarts, and everything is reset. If objects are global, that won't be the case. If you base settings on Globals, that won't happen until Globals are reset. So it does depend on your code/CAPX.

  • Yeah I know what you mean, I usually just don't trust the restart event and go with my own ' on function "reset" '.

    Depends on how much stuff you need to restart I suppose.

    Having said that I just created a blank project to play around with resetting stuff.

    I added 2 sprites, 1 for position, 1 for visibility. I added a variable which was displayed via a text object and set through a textbox object. Also added a button to go to layout 2.

    From layout 2 I had a button that, "on click" calls: System>Go to Layout 1 & System>Restart Layout & System>Reset Global Variables to default.

    Layout 1 does reset properly from layout 2. The global variable gets zeroed, positions and visibility all go back to initial states.

    I'll add that I was surprised to find that BOTH layouts got reset.

    If a sprite gets it's Visibility from a global variable (eg. if x=1 sprite invisible) AND you DON'T Reset Global Variables to default then a "restart layout" wont effect it's visibility.

    System>Restart Layout

    System>Reset Global Variables to default

    That should Nuke everything back to 0.

    If not, Write a Function that sets everything how you want it to be and call it On Start of Layout.

    here's another way that just came to mind:

    Menu layout, start game button > goes to Layout "Game" & sets a Variable "new_game" to 1.

    On Start of Layout "Game", if "new_game" = 1 Restart Layout & Set "new-game" to 0.

    By the way, probably isn't related to your question but you can right click on Variables and send them to other Event Sheets.

    Oh and use Local variables where needed, which can be added to Groups.

  • Thanks!

  • Xeeko,

    System>Reset Global Variables to Default might be what you are looking for

    I've only seen demos of Fusion, but it looked to me like the people running the demo (a high school teacher and her student) used a lot of global variables. I try to stay away from global anything as much as possible in C2 because it can make troubleshooting very difficult. The exception to this is "included" event sheets, which have been really helpful for my latest project.

    As for Layouts/Event Sheets, if you duplicate a layout, the duplicated layout will use the previous event sheet, which you then need to reassign to a new event sheet. If you create a new layout from scratch, it will prompt you whether or not you want to create a new event sheet to go with it. In my current project, I have found that it is easiest to duplicate the layout, then create a new event sheet in the event sheet sidebar.

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