Global HUD Help

Get help using Construct 2

Post » Wed Aug 28, 2013 1:13 pm

Hi,

I'm attempting to implement a global HUD into my game suggested here: http://www.scirra.com/forum/forum_posts.asp?TID=60238&PID=370258&title=inherited-layer-cross-multiple-layouts#370258

I'm trying to load the HUD automatically at the start of each level. It is probably easiest to explain in program form

GLOBALEVENTS:
     HudLoaded = 0
     IF HudLoaded == 0
          GOTO LOADHUD              

LEVEL 1:
    IMPORT GLOBALEVENTS
     ON LEVEL_END
          TURN HUD OFF
          
LOADHUD:
     HudLoaded = 1
     GOTO LEVEL 1

Obviously, this creates a loop. How can I create a global variable that is not reset every time the event sheet it is on is loaded? One solution would be to load globals at the beginning of the game, however this won't work if I am debugging.

How should I approach this?

Bituser2013-08-28 13:21:36
B
3
Posts: 9
Reputation: 193

Post » Wed Aug 28, 2013 1:23 pm

Global variables don't reset unless you ask them to. If you 'include' the event sheet on more than one layout the global variable shouldn't change value between layouts.
B
45
S
15
G
73
Posts: 2,014
Reputation: 43,410

Post » Wed Aug 28, 2013 1:38 pm

Global's don't reset unless you use "Reset global vars"

And if you need to reset some Global vars and not all of them then:

At the end of layout > Set "OtherGlobalVariable eg 'Health'" to 100
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Wed Aug 28, 2013 1:45 pm

Dont use there global variables, use local variables they reset automatically.
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Wed Aug 28, 2013 2:11 pm

Thanks guys. Got it sorted. t turns out my "Return to original level" was setup wrong. I'm glad I know about the globals now!
B
3
Posts: 9
Reputation: 193


Return to How do I....?

Who is online

Users browsing this forum: mikehive, OddConfection and 12 guests