Make a game start from level but then from menu as you close and reopen the game

Jovial Games

  • Posts: 122
Hey guys,

I'm working on creating a mobile game for android and iOS. I was wondering if I can make a mechanic that when a user freshly opens my game it starts from the level but then when he closes the app completely and reopen it, it starts from the main menu instead of the level.
Is there a way to make this mechanic? If so, can you please guide me thoroughly how to do it?


Thanks!

merrak

  • *
  • Posts: 2076
You could set a boolean game attribute when the app is launched. Save it and when the app loads, check for its value. If it is set true then you know the game has been opened before and can direct the player to the menu instead of the first level.

Jovial Games

  • Posts: 122
This would go like
if the boolean game attribute is true value

When created
set SwitchtoMenu = false
save game
load saved game
if SwitchtoMenu = false
switch scene to mene

Is this right? Cuz for some odd reason this isn't working for me

Luyren

  • *
  • Posts: 1457
Use the load game block before everything else.
Working.

designpeg

  • *
  • Posts: 595
You can use the loses focus and regains focus blocks (loses focus fires when you close a game, or answer call etc), the code may not run until you go back to it, Regain should be self explanatory.

Jovial Games

  • Posts: 122
Will it be like

When updating
load saved game
set SwitchtoMenu = False
save game
if SwitchtoMenu = False
Switch scene to Menu

What's better? when updating or when created?

Luyren

  • *
  • Posts: 1457
When Created
-Load Game
--If SwitchtoMenu
Switch to Menu Scene
--Otherwise
Set SwitchtoMenu to true
Save Game

This ought to work.
Working.

Jovial Games

  • Posts: 122
Thank you Luyren!
I really appreciate this :D