Do Something only once

Get help using Construct 2

Post » Thu Oct 11, 2012 4:46 pm

Until now, I have been doing my static initialisation in a "on start of layout".

However, on mobile, the user can switch between portrait and landscape layouts. Each time they switch back to portrait, I am guessing that "On start of layout" is run (although I dont know this for sure).

The question is, how to only run something once ever, no matter how many times the layout is swapped?

E.g. could I do:

[CODE]
Global DoneInit = 0
System DoneInit = 0 -> System set DoneInit to 1
                    -> (do static initialisation of stuff)
[/CODE]              

And this only ever get called once, or do global vars also get re-initialised when you switch layouts?
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Thu Oct 11, 2012 5:07 pm

Your example should work fine, only running once ever (during the running of the project). 'On start of layout' is only ever run at the start of layout and is not called again even if the orientation/window size changes.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600


Return to How do I....?

Who is online

Users browsing this forum: grigrizljac, GSquadron and 22 guests