Global layer problem

0 favourites
  • 14 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.
  • 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^^

  • Ezekiel

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

    Subscribe to Construct videos now
  • No I did not and no I have not. Let my try that. Although I HATE video tutorials^^

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

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

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

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

  • I reported this in the past:

    But they don't want to change it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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

  • None of you reading what I previously wrote means none of you are helpful. Except Prominent who actually read what i wrote.

    But it's okay, i'll figure it out on my own...

  • I read everything in the thread actually and fully investigated it. The example from Prominent is exactly what I described and accurately GUESSED you were doing. I checked the .capx. You shouldn't set the object to Global and put it on a Global layer, it's flawed logic and it's as designed in C2.

  • I already said, I REMOVED that right away. So your investigation probably skipped that part. Anyway, i found a solution involving Global Variables, something I wanted to avoid but whatever. I still thank you for your time and effort, though.

  • YES, thank you.

    I had missed adding "HUD" as a non global layout, to be overridden by the global layout "HUD" in my other Layout.

    That little trick... WORKS!

    Great tutorial, follow it, it'll work.

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