How to detect if the game was closed?

0 favourites
  • 3 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • Ay bois, so, this time i want to do an type of system for my game, that detects if the game is closed, like to count how many times the game was closed. I don't know a way to do this, either i have tried some, if you know how, please tell me!

    Objective: If the player closes the game, or, the game closes itself, will detect it, then, apply an type of value to a LocalStorage.

  • Create a variable number = 0

    On Start of layout, compare if it is = 0 (Means that the game was restarted)

    - Set the value to LocalStorage

    - Set the variable to = 1

    You can also do it using On suspended but I don't think that it works when you close the app, is probably easier just to compare if its a fresh run.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Create a variable number = 0

    On Start of layout, compare if it is = 0 (Means that the game was restarted)

    - Set the value to LocalStorage

    - Set the variable to = 1

    You can also do it using On suspended but I don't think that it works when you close the app, is probably easier just to compare if its a fresh run.

    That should do the trick, thanks bro!

    Edit: Actually that worked, but, in a way that i didn't want tho. Like i said, i somehow want to detect if the game was closed when it's closed, because, i'm making a bullet hell game, that the number of deaths will be crucial to this, so, if the player is about to die and then closes the game to restart the fight 'fast', will just mess up with the death system. If the player reaches a certain amount of deaths ( that are saved in a local storage ) will trigger some functions, if the player closes the game, won't count as a death, that's why i'm looking forward this. Btw, thanks for the help too!

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