Difference between "Global" and "Persist"?

Get help using Construct 2

Post » Mon Aug 25, 2014 11:18 am

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?
B
28
S
18
G
8
Posts: 333
Reputation: 6,193

Post » Mon Aug 25, 2014 11:43 am

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
B
25
S
3
G
1
Posts: 67
Reputation: 2,971

Post » Mon Aug 25, 2014 11:49 am

fisholith wrote: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.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Thu Aug 28, 2014 9:49 am

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. :)
B
28
S
18
G
8
Posts: 333
Reputation: 6,193

Post » Thu Aug 28, 2014 10:26 am

fisholith wrote: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.
Image
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. :mrgreen:
B
28
S
8
G
4
Posts: 553
Reputation: 4,924


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests