How do I make a global HUD?

0 favourites
  • 7 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hello,

    I have multiple layouts, they all share the same HUD.

    I made the HUD layer Global, it worked, but the Coins text resets its text whenever I go to another layout. I want the text to preserve its value.

    I tried to make the text object use the Persist behavior. It worked, but now the text duplicates. Maybe because the global layer already has a text instance + the Persist instance ?

    Currently I made a function called Refresh, which is called on every On Start Of Layout event to update the text HUD contents. But with a lot of layouts, this is inefficient.

    How do I make a global HUD that preserves the values of its contents between layout transitions?

    Thank you.

  • You could make the objects global (not on a global layer) and use persist but this is kind of messy as you have to pick instances. I prefer to have the global hud layer for visual side and instead use global variables, this is more the norm I would think.

    The inefficient function you talk about, you are always going to need something to set the displayed values. You can either put it at the top of each event sheet or call it from one main event sheet that links to all layouts.

  • You could make the objects global (not on a global layer) and use persist but this is kind of messy as you have to pick instances. I prefer to have the global hud layer for visual side and instead use global variables, this is more the norm I would think.

    The inefficient function you talk about, you are always going to need something to set the displayed values. You can either put it at the top of each event sheet or call it from one main event sheet that links to all layouts.

    Thank you. I use variables as well, but I don't poll them; instead, I update them only when they change.

    That is why adding a Polling function that would update each object again (I can't use a loop, because they are of different object types) is redundant in my case.

  • I often stuff several hidden global object on layer 0 somewhere ( 0, -1000), which holds all my game values. Several actually, depending on game structure, an object for player related info, an object for game stats or game element stats. (Also easy for saving: asjason)

    Using a hud group in the game's main event sheet, or dedicated hud event sheet which gets included, I sometimes use on start of layout in there to fill the preliminary hud information, or do a hud setup (positioning).

    If it gets loaded each time a layout is started, meh, that's supposed to happen me thinks ^_^ visually it wont make a difference.

    In the hud section I often use every x second and set it to 1 second, for HUD updates, life bars, feedbacks popups etc etc. The 1 second things make the entire process lightweight processing wise.

    As a suggestion, avoid using global variables to hold game status or player earned in game goodies etc .... global variables ... the name should give it away really. Is relatively easy accessible from outside the game.

    Using object variables eliminates a lot of potential unwanted intrusion to values or variables used by your game. (the fact on a object can be global and hold variables, is not the same as a global variable)

    By no means will this make your game 100% secure, but will most definitely make it harder to cheat.

  • I often stuff several hidden global object on layer 0 somewhere ( 0, -1000), which holds all my game values. Several actually, depending on game structure, an object for player related info, an object for game stats or game element stats. (Also easy for saving: asjason)

    Using a hud group in the game's main event sheet, or dedicated hud event sheet which gets included, I sometimes use on start of layout in there to fill the preliminary hud information, or do a hud setup (positioning).

    If it gets loaded each time a layout is started, meh, that's supposed to happen me thinks ^_^ visually it wont make a difference.

    In the hud section I often use every x second and set it to 1 second, for HUD updates, life bars, feedbacks popups etc etc. The 1 second things make the entire process lightweight processing wise.

    As a suggestion, avoid using global variables to hold game status or player earned in game goodies etc .... global variables ... the name should give it away really. Is relatively easy accessible from outside the game.

    Using object variables eliminates a lot of potential unwanted intrusion to values or variables used by your game. (the fact on a object can be global and hold variables, is not the same as a global variable)

    By no means will this make your game 100% secure, but will most definitely make it harder to cheat.

    Thank you. I've used objects to hold values before, but never on this scale.

    Very good point regarding cheating.

    I really hope C3 gets a way to make global huds someday. Maybe an "additive layout" (like unity) where the layout contains the HUD, and this layout van be overlayed on any other layout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I really hope C3 gets a way to make global huds someday. Maybe an "additive layout" (like unity) where the layout contains the HUD, and this layout van be overlayed on any other layout.

    Hmm, did you grasp the concept of a global layer ?

    On one of the game layouts, add a layer at the top, call it HUD (or whatever fancies your hud layer name) in the layer settings on the left, click the "global" option.

    Now, on another layout, simply add a new layer called "HUD" (or the selected name) and wham, all the details, objects and positioning from the previous layout hud layer is there too in the new layout.

    So, you can build 1, or even multiple HUD layers, set them global, and include them in every layout you desire by means of adding a new layer and giving it the same name as the one you set globally.

    I have a game with different game mechanics on layouts (platformer side view and top down) and use 2 different HUD layers (HUDplatform, HUDtopdown) These layers get added to the required levels (layouts).

    I created the layers for the HUD on my Objects layout (to hold all my initial objects), so all my tinkering is done there, and reflected on the layouts where ever I include the layers.

  • > I really hope C3 gets a way to make global huds someday. Maybe an "additive layout" (like unity) where the layout contains the HUD, and this layout van be overlayed on any other layout.

    Hmm, did you grasp the concept of a global layer ?

    Yes. I think I did not clarify my last comment.

    What I meant is a system that includes not only Global layers, but saving items state across global layers (the coin example I mentioned above).

    Also, at the moment setting a layer as Global doesn't convert its sub-layers as well. I still need to add them one by one to each layout.

    Maybe one day we will be able to set a layer Global without the need to add it to each individual layout.

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