Difference between "Global" and "Persist"?

0 favourites
  • 5 posts
  • So far, what I think I understand is:

    It looks like "Global" objects exist across all layouts, with all their state information being globally consistent and available all the time, independent of any single layout. (e.g. Even their position in a layout will be preserved across layouts, as well as their layer number, (not name).)

    It looks like objects with the "Persist" behavior, have their state information tied to their home layout, however that state info is saved on exiting the layout, and restored on reentering the layout.

    Is that kind of what's going on?

    Also, What happens if an object is "Global" and has the "Persist" behavior? Does that cause conflicts? Would there even be any point, or are Persist characteristics essentially subsumed by Global characteristics?

    Other interesting stuff about globals I've come across:

    Global or not, object instances placed in layouts don't seem to get spawned until the layout is executed, and so global object instances placed in a layout will not exist until that layout is first executed.

    A global object instance, once created, and then destroyed, will not be recreated if you return to the layout that first spawned it. So, I guess the layout knows that it already spawned that global object instance and won't do it again until the game is restarted?

    This seems to be the case even if in the editor, you place a global object instance in "Layout_A", then run "Layout_A" to spawn the placed global, then destroy it in "Layout_B", and then return to "Layout_A". The global object instance will stay dead.

    Is there any other interesting stuff worth knowing about Global or Persist?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I guess you know more than me on that, I don't use global objects in my games,though I know how to use them,it could be helpful for someone with lots of levels and use global objects for UI interface. But since I finish designing my game concept and UI then start on the level development By duplicating the layout. it's not helpful to me

  • Is there any other interesting stuff worth knowing about Global or Persist?

    My discovery with persist is, it is extremely helpful when I create multiple array filters, used it mainly with the checkbox. It's complicated, but yeah it's a lifesaver at least for me.

  • Thanks for the replies.

    DuckfaceNinja, could you explain the multiple array filters you mentioned? I'm not sure what you mean, but it sounds interesting.

  • Thanks for the replies.

    DuckfaceNinja, could you explain the multiple array filters you mentioned? I'm not sure what you mean, but it sounds interesting.

    It's rather complicated to put in words, the UI is similar to picture below, only the way it works is in the background is complex.

    Normally to filter just data, persist is not necessary for the check-boxes but I found out that, visual filter which involves complex amalgamation between arrays and sprites (instance variables, sprite IID, array sorting, ... , the list goes on), restarting the layout is necessary, so persist kinda goes well with restarting the layout.

    Restart layout & Persist check-box, is actually my workaround to my problem. I think it can be done better, eliminating the need of using persist, it just that things are just too complicated when I need to call a lot of functions, it tends to be buggy because there are things that are meant to built only once, but cause mayhem to everything instead, it's a long story, because I hit the ceiling of logic limitation which is the impossibility of closing never-ending loop.

    Best way to clear everything was by restarting the layout and rebuild the data according to the checkbox filter which retained after the restart, simply a no brainer solution with the existence of persist.

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