How do I display a Layout above another layout?

0 favourites
  • 9 posts
  • 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.


  • 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.

  • 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?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a fantastic tut in the tutorial section which walks you through this. It loads a gui layout over another layout.


    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.


    Thanks again, it seems to be the best approach.


    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.


    I struggled to use the function. I did not know what to put as Parameter <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    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. ... ample.capx

  • I looked at your capx 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.

  • It'S strange 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.

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