How do I detect if the game is run for the first time?

Get help using Construct 2

Post » Thu Jun 23, 2016 2:45 pm

On start of layout will happen every time the layout is started. Whether it is in the same execution, or not.
Nevertheless, when you are executing your game on a device for the very first time, there is NO local storage key existing on the device for the game.

So you know you want to display the tutorial.
Also, your code is supposed to be made so that when a key doesn't exist, it creates one.

Once the game has been executed once, the key has been created, the next time the layout is started (whether in the same execution, or later), "On start of layout" checks if the local storage key exists. This time it does.
So you go to a different event, in which you remove your tutorial elements.

It's the logic of how local storage works.
No magic this way, and you are using the local storage how it is supposed to be used.
Image
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Fri Jun 24, 2016 8:50 pm

@Kyatric My mistake was that I wasn't checking if it existed, I just jumped to on missing. Got it now :) thank you!!!
B
37
S
6
G
1
Posts: 301
Reputation: 2,865

Previous

Return to How do I....?

Who is online

Users browsing this forum: AndreasR, tarek2 and 12 guests