Global layer problem

Get help using Construct 2

Post » Tue Aug 09, 2016 9:11 pm

So I created a global layer for my hud, which is nice. THe problem is every time i change layout, the engine adds all events on that layer, basically duplicating them. so on layout 8 i already have 9 HUDS over each other, that of course eats framerate considering i have over three dozen layouts. any suggestions as to why and how to fix that?

I use the latest beta^^
B
7
S
2
Posts: 66
Reputation: 720

Post » Tue Aug 09, 2016 10:54 pm

@Ezekiel

Did you build this layer on a separate layout without an event sheet? Have you seen this video? :

https://www.youtube.com/watch?v=X1BZHu6Nwd8
B
16
S
9
G
5
Posts: 74
Reputation: 4,120

Post » Tue Aug 09, 2016 11:35 pm

No I did not and no I have not. Let my try that. Although I HATE video tutorials^^
B
7
S
2
Posts: 66
Reputation: 720

Post » Tue Aug 09, 2016 11:51 pm

Okay I tried that and exactly the same thing happens. Every time i load a new layout everything on the global hud is loaded too, resulting in everyhting being doubled...
B
7
S
2
Posts: 66
Reputation: 720

Post » Wed Aug 10, 2016 1:22 am

Okay I narrowed the problem further down.
i have a global layer and on this layer i have some graphics and a font. every time a new layout is loaded all things in the layout INCLUDING the global layers are re-created. everything reset for some reason so i made my objects on the global layer global as well. now they stay AND get recreated, explaining the doubling.
but why are they recreated every time i load a new layout, isnt that what global is for, to prevent that inthe first place? and why only with layouts i visit for the first time? if i visit a layout again, it doesnt happen.
B
7
S
2
Posts: 66
Reputation: 720

Post » Wed Aug 10, 2016 1:48 am

@EzekielRage

I was just going to ask you about that.... Global objects are for objects that persist through a game. For example, if you want your player to change layout and keep his instance variables, you need to make him global. Layouts keep their data until you reset them on a "game over".

So your HUD elements should not be set to global, just the layer should be (one or the other, but for logistical purposes, the separate layout is better).
B
16
S
9
G
5
Posts: 74
Reputation: 4,120

Post » Wed Aug 10, 2016 3:13 am

i know all that. the problem is that the layer DOES NOT keep the data but resets it. thats the whole problem why i tried global objects to be gin with shich i removed already. the problem still stands that everything on the global layer keeps getting reset and no, there is no code issue as i put it on a seperate layout without event sheet as per your suggestion.
B
7
S
2
Posts: 66
Reputation: 720

Post » Wed Aug 10, 2016 3:18 am

I reported this in the past: viewtopic.php?f=152&t=176302
But they don't want to change it.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Wed Aug 10, 2016 4:09 am

@EzekielRage

Obviously, without a capx, I can't tell if there is a flaw in your code, but it seem by what you are saying that it would be best for you to drop the global layout and go for the global HUD objects. Note that for this to work, all the layouts MUST have the same layers (name+order) for global objects to carry through. Also, global objects have to be loaded for them to appear in a new layout, so if you set your objects in a separate layout, you must first load it and then on start of layout exit it right away.
B
16
S
9
G
5
Posts: 74
Reputation: 4,120

Post » Wed Aug 10, 2016 12:19 pm

It's because you set the object on the global layer to global so every time you switch layout it's doing the following :
Go to Layout 2 > Load Global Layer with Global Object 1
Go to Layout 3 > Load Global Layer with Global Object 2, Global Object 1 remains as it is global
Go to Layout 4 > Load Global Layer with Global Object 3, Global Objects 1 and 2 remain as they are global.


If the HUD elements are going to be updating between layouts and it's important that they persist then just make every object on the HUD a global object. If you want to do it with a layer then do not make the objects on the layer global, only the layer.
B
45
S
15
G
73
Posts: 2,021
Reputation: 43,424

Next

Return to How do I....?

Who is online

Users browsing this forum: bluesun66, HenryPK, Malhog, plinkie, Syazanie Amirin and 1 guest