Jump to content


Photo

neat way of saving user's settings?


  • Please log in to reply
11 replies to this topic

#1 ObsidianNovels

ObsidianNovels

    GMC Member

  • GMC Member
  • 351 posts
  • Version:GM:HTML5

Posted 08 July 2012 - 05:02 PM

I let the user alter settings such as colors and such in my app. I thought I was clever when I decided to let the app write an .ini-file to store them, but then I learned that Apple won't accept apps that uses the game_end()-command.

Anyone got a clever suggestion on where to have my app write the .ini-file instead? I'm thinking about letting it be saved every 10 second or so in the step-event, provided it won't slow the app down in some way.

Is there a better solution?
  • 0

#2 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 08 July 2012 - 05:05 PM

Have it save when the user sets the settings/changes. So If i picked blue then hit ok to get back to game, have it save there.
  • 0

#3 wagdog

wagdog

    GMC Member

  • GMC Member
  • 268 posts
  • Version:GM:Studio

Posted 08 July 2012 - 05:23 PM

I save to an ini as soon as the player changes anything, and as soon as the player achieves something in the game that needs saving.
  • 0

#4 Kouri

Kouri

    GMC Member

  • GMC Member
  • 157 posts
  • Version:GM:Studio

Posted 08 July 2012 - 06:39 PM

Saving on game_exit is a bad idea in the first place. If some error causes the game to crash, or if the mobile OS closes the background app, the player loses any and all data since (s)he started playing.

Look for specific events to call the ini save features. And information that changes should be saved, but only save -after- the changes are complete. For example, you wouldn't update the high score every time it goes up a point, but rather at a point where the score would stop rising, such as a Game Over.

Settings:
  • When exiting the settings menu (whether on the main menu or within a pause menu).

High Score:
  • Game Over.
  • Between Rounds.
  • Returning to the Main Menu

Achievements
  • Upon achieving

RPG games would probably work a bit differently. Aside from achievements, which should always be saved right away, all of the other information would probably only be saved at the in-game save points, whether manually or automatically.
  • 0

#5 ObsidianNovels

ObsidianNovels

    GMC Member

  • GMC Member
  • 351 posts
  • Version:GM:HTML5

Posted 08 July 2012 - 08:11 PM

Well, actually it's an e-book I'm working on, and I want my app to automatically bookmark the current page so that it is being loaded every time the reader runs the app again. The color settings are in a different menu.
So one way would be to simply save the page-variable every time the reader turns the page, but then it would likely cause lag.
I suspect it's fairly easy to just change one line in the .ini-file, because of its neat structure, correct?
  • 0

#6 Kouri

Kouri

    GMC Member

  • GMC Member
  • 157 posts
  • Version:GM:Studio

Posted 08 July 2012 - 08:50 PM

Well, actually it's an e-book I'm working on, and I want my app to automatically bookmark the current page so that it is being loaded every time the reader runs the app again. The color settings are in a different menu.
So one way would be to simply save the page-variable every time the reader turns the page, but then it would likely cause lag.
I suspect it's fairly easy to just change one line in the .ini-file, because of its neat structure, correct?


I've been saving one or two lines at a time with no noticeable lag or freeze. But a way to limit the frequency of saving would be to set an alarm for 5 seconds every time the user turns a page, and then save when the alarm runs down. This way, users that flip through pages quickly don't have the app constantly trying to save, because the alarm resets every page until the user stops to read.
  • 0

#7 wagdog

wagdog

    GMC Member

  • GMC Member
  • 268 posts
  • Version:GM:Studio

Posted 08 July 2012 - 10:47 PM

There is no noticeable lag when saving a variable or two to an ini. Try it, I think you'll agree.
  • 0

#8 ObsidianNovels

ObsidianNovels

    GMC Member

  • GMC Member
  • 351 posts
  • Version:GM:HTML5

Posted 09 July 2012 - 03:31 PM


Well, actually it's an e-book I'm working on, and I want my app to automatically bookmark the current page so that it is being loaded every time the reader runs the app again. The color settings are in a different menu.
So one way would be to simply save the page-variable every time the reader turns the page, but then it would likely cause lag.
I suspect it's fairly easy to just change one line in the .ini-file, because of its neat structure, correct?


I've been saving one or two lines at a time with no noticeable lag or freeze. But a way to limit the frequency of saving would be to set an alarm for 5 seconds every time the user turns a page, and then save when the alarm runs down. This way, users that flip through pages quickly don't have the app constantly trying to save, because the alarm resets every page until the user stops to read.



Good idea, I'll try that then.

Thanks!
  • 0

#9 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 417 posts
  • Version:GM:Studio

Posted 09 July 2012 - 05:22 PM

Couldn't you use the OS Pause Event?

Like on iOS it should trigger when the user exits an application using the Home key, this seems like the perfect moment to save data like what you describe.
  • 0

#10 ChefDavid22

ChefDavid22

    No, YOU shut up!

  • GMC Member
  • 1193 posts
  • Version:GM:Studio

Posted 09 July 2012 - 05:51 PM

There is no noticeable lag when saving a variable or two to an ini. Try it, I think you'll agree.


This really is the best way. All you need to do is to detect the page turn and update the ini file. It's only called once per page, and closed almost immediately. Resource use is not seen.

On my game Zomboozled I open and ini and check for 20 achievement variables every single round and even that is not noticed.
  • 0

#11 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 2847 posts
  • Version:GM:Studio

Posted 09 July 2012 - 06:29 PM

Once it happened to me that i noticed a liiitle constant lag on my Android device, but it wasnt there on windows. What was going on? I accidentally was calling my saving script on a step event, wich opened an ini, wrote all the current data then closed it. Thats how fast ini's are now on Studio :)

Edit: I noticed about this only because I use old devices to test on, on newer devices I would probably never realize about it..

Edited by Manuel777, 09 July 2012 - 06:31 PM.

  • 0

#12 ObsidianNovels

ObsidianNovels

    GMC Member

  • GMC Member
  • 351 posts
  • Version:GM:HTML5

Posted 10 July 2012 - 08:25 PM


There is no noticeable lag when saving a variable or two to an ini. Try it, I think you'll agree.


This really is the best way. All you need to do is to detect the page turn and update the ini file. It's only called once per page, and closed almost immediately. Resource use is not seen.

On my game Zomboozled I open and ini and check for 20 achievement variables every single round and even that is not noticed.


I went with that one. Think it'll run smooth, but I'll try it on my Android tomorrow to be sure. =)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users