Selection option when the app runs for the first time?

I want the player to choose a class the frist time he/she runs the app. My current solution is to look for the highscores file my game creates, and if the file does not exist then I will send them to the choose lua file.

My questions are:

Are there an alternative better method to do this or is my solution sufficient?

Can this method cause any problems?

As good a solution as an, some create a specific empty text file just for this purpose, but checking for the existence of a high scores or settings file is just as good.

Okey thank you:) I was just worried it would cause some problems or that it was a bit noobish.

I generally have a “settings” file which isn’t created until the app runs the first time. If that file doesn’t exist, then you know it’s a first run, or the app was deleted and re-installed in which case, you want to use your “first run” logic anyway.

You can also use the system.getPreference() and system.setPreferences() APIs to do the same thing. It might be a little less code to use these APIs: http://docs.coronalabs.com/api/library/system/getPreference.html

local hasAppRunBefore = system.getPreference( "app", "hasAppRunBefore", "boolean" ) if not hasAppRunBefore then      system.setPreferences( "app", { hasAppRunBefore = true } )      -- do your first run logic here end

(untested code)

Rob

I think that the preference solution fits better. Thank you for including an example, I will use that and add a another line if the hasAppRunBefore is true then it will go to the menu insted.

As good a solution as an, some create a specific empty text file just for this purpose, but checking for the existence of a high scores or settings file is just as good.

Okey thank you:) I was just worried it would cause some problems or that it was a bit noobish.

I generally have a “settings” file which isn’t created until the app runs the first time. If that file doesn’t exist, then you know it’s a first run, or the app was deleted and re-installed in which case, you want to use your “first run” logic anyway.

You can also use the system.getPreference() and system.setPreferences() APIs to do the same thing. It might be a little less code to use these APIs: http://docs.coronalabs.com/api/library/system/getPreference.html

local hasAppRunBefore = system.getPreference( "app", "hasAppRunBefore", "boolean" ) if not hasAppRunBefore then      system.setPreferences( "app", { hasAppRunBefore = true } )      -- do your first run logic here end

(untested code)

Rob

I think that the preference solution fits better. Thank you for including an example, I will use that and add a another line if the hasAppRunBefore is true then it will go to the menu insted.