How do I properly restart a layout?

Get help using Construct 2

Post » Thu Jun 02, 2016 2:13 pm

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?
B
10
S
3
Posts: 63
Reputation: 776

Post » Thu Jun 02, 2016 2:15 pm

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
B
13
S
5
G
4
Posts: 119
Reputation: 3,353

Post » Thu Jun 02, 2016 2:32 pm

Providing a capx can help us better understand what you need. :)
I like giving game advice more than I actually like making games ;)

Image
B
40
S
15
G
3
Posts: 129
Reputation: 4,651

Post » Thu Jun 02, 2016 3:23 pm

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?
B
10
S
3
Posts: 63
Reputation: 776

Post » Thu Jun 02, 2016 3:45 pm

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.
ImageImageImage
B
71
S
22
G
240
Posts: 3,733
Reputation: 133,992

Post » Thu Jun 02, 2016 4:30 pm

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.
B
7
S
1
Posts: 43
Reputation: 513

Post » Fri Jun 03, 2016 8:39 am

Thanks!
B
10
S
3
Posts: 63
Reputation: 776

Post » Fri Jun 03, 2016 5:59 pm

@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.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
48
S
14
G
24
Posts: 400
Reputation: 16,648


Return to How do I....?

Who is online

Users browsing this forum: lahbach, newt and 35 guests