Inherited Layer cross multiple layouts?

Discussion and feedback on Construct 2

Post » Sun Nov 25, 2012 10:56 am

Folks,

Do you know if we have this feature in C2? mainly used for HUD and HUD events so we don't have to tweak the HUD on each level.

I searched forum and found its available in Construct Classic

http://www.scirra.com/forum/hidden-feature-9-inherited-layers_topic37103.html
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Mon Nov 26, 2012 8:55 pm

I have a work around for this that I am pretty proud of. Steps are as follows.


Make sure all your layouts have the same number of layers. Good practice anyway. Including a blank HUD layer.

Create a specific HUD layout, with the same number of layers.

Put the HUD elements on the HUD layer in the HUD layout.

Make them global.

I organise my game events in a single event sheet - so this is how i do the next step.

On load layout, I store the name of the current layout in a global variable.

Load the HUD layout.

In the HUD's event sheet (not the main event sheet), you have an On Level Loaded event which then loads the layout whose name you stashed in the global variable.

So basically, whichever layout you load, it immediately loads the HUD layout, which is all globals. And the HUD layout loads the original level back in. The global HUD is preserved. It works perfectly. :)


B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Tue Nov 27, 2012 4:30 pm

Ahh nice! I will try it out, thanks very much :D
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Wed Nov 28, 2012 10:48 am

@foolberry, I'm get stuck, several questions:

1. how to get the layout name in event? eg I have a global variable called CurrentLevel in my GenericGameplay eventsheet.
2. in the HUD eventsheet, when layout loaded, do you mean the action called "Go to layout by name"?
3. Do I need the same layer setup in the HUD layout as well?

thanks for help!
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Wed Nov 28, 2012 2:20 pm

I figured it out:D. if not misunderstanding:

1.set global variable CurrentLevel = layoutname in level layout. set global variable IsHUDLoaded = 0.
2. if IsHUDLoaded = 0, goto HUD layout.
3. in HUD layout, set IsHUDLoaded = 1. then goto layout by name CurrentLevel.

but there is one problem left: if I quit to Main menu, which is a simple layout when game start. the HUD objects are there too. how do I remove them?
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Wed Nov 28, 2012 10:12 pm

Hmm. Never had to do that. Ultimately it's just about deleting or making invisible those HUD objects.

I'd just do it all in a function - make them all invisible.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests