How do I display a Layout above another layout?

Get help using Construct 2

Post » Tue Apr 15, 2014 4:42 pm

Hi everyone,

Is it possible to display a Layout above another layout in C2?

I don't want to use Layers because I would like to create several layouts for my UI options that could be called on different Game layouts and I would like to keep the Game Layout below.
Imagine that each Game Layout is a new level / world.

I don't think to copy/paste all UI layers on each Game layout is effective.

Thanks
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Tue Apr 15, 2014 4:45 pm

You could just create a Function to load a particular GUI based on the layout you're using at the time. That way, you don't have to worry about copy/paste the UI each time you add another layout. Just call the function at the Start of the layout and it creates the objects necessary for your HUD/GUI, based on global variables you have setup and whatnot.

To answer your question, I do not believe it is possible to display a layout above another layout; layers would be what you'd likely need here. Again, you could likely accomplish that with a function as well.
B
7
S
1
G
1
Posts: 56
Reputation: 732

Post » Tue Apr 15, 2014 4:56 pm

Thanks Punkineo.

Indeed, I did not think about Function.

If I do this, does it mean that the datas of UI are duplicated?
Meaning that the app will be heavier or it will only load the datas once for all game layouts?
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Tue Apr 15, 2014 7:24 pm

Right, I don't think your app will be heavier if you use a Function to generate the HUD/GUI per Start of each layout. It will only load the data once for all game layouts as it needs to. So, if you have 5 layouts with 5 calls to the same function for generating your HUD/GUI, it's similar to having one layout since the system only sees the one layout each time it draws it to the screen. I'm sure others with a better understanding of the memory-usage could explain this better than me. Suffice to say, you should be completely fine using functions for creating your HUDs for each separate layout.
B
7
S
1
G
1
Posts: 56
Reputation: 732

Post » Tue Apr 15, 2014 7:30 pm

There is a fantastic tut in the tutorial section which walks you through this. It loads a gui layout over another layout.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Wed Apr 16, 2014 12:51 pm

@DUTOIT:
Thanks for the TUT but it does not work for what I want to do.
In the TUT, it is mainly to display a UI from the start of the layout, I tried to use the same approach but when the Player dies, I want the game to display the Result window. which is different.

@Punkineo
Thanks again, it seems to be the best approach.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Wed Apr 16, 2014 1:28 pm

@DUTOIT
My apologies DUTOIT, I tried it again in order to do a quick example and the secret is that I have to create a Main Menu first in order to load each Layout I need to.

@Punkineo
I struggled to use the function. I did not know what to put as Parameter :(

Here is a capx example of what I want to do. Let me know what you think about and if this is the correct way or if you have a better way.

https://www.dropbox.com/s/qdkt5bqm9ium8 ... ample.capx
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Thu Apr 17, 2014 3:04 pm

I looked at your capx @Underdog. It looks like your UI layout will never come up because of this event:
System / On start of layout / System / Go to Game

So, as soon as someone clicks on Text3 [New Game] from the MainMenu, it loads layout Game instead. But I also see the events for E_Game where you set the layer UI_Result to Visible. Of course it doesn't work, but I think it's due to the layer for UI_Result not residing on the current layout for E_Game. Not sure if this helps any, but just my observations.
B
7
S
1
G
1
Posts: 56
Reputation: 732

Post » Fri Apr 18, 2014 6:51 pm

It'S strange @PunKineo. It works here. Did you try to die? The idea is to make appear the UI window above the Game layout if the Player dies :)

Thanks for checking.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests