playMaker

Author Topic: Saving language setting/player prefs  (Read 2628 times)

Slater

  • Full Member
  • ***
  • Posts: 123
Saving language setting/player prefs
« on: August 09, 2012, 12:52:14 PM »
In my intro scene I have built a settingspanel for the user to be able to set what language they want to have on my app for iOS. The state machine works like this:

Start - State 1. "Touch GUI Event" x 3. Transitions onTouchSwedish onTouchEnglish onTouchGerman. The transitions lead to 3 separate states, Swedish, English and German. In those states I use "Set GUI Text" on another GUI Text object and then it has FINISHED and transitions back to State 1 in order to be able to switch again. I had to put in a wait for 0.1 in the language states since otherwise it didn't transition back through FINISHED to state 1.

What I am struggling now with is how I will go about to "save" the chosen language setting and "pick it up" in other scenes. When I go in to another scene I already have an FSM in their playing audio and text as if it was a cartoon with narrative voice and subtitles. However I need to make the FSM know what language it should write the subtitles in and what language the voice should be in. So how do I save it and pick it up in an other scene?

As far as I understand it I should use Player Prefs. Thats about as far as I have gotten :) Please help me, Im really the super noob here :)


Slater

  • Full Member
  • ***
  • Posts: 123
Re: Saving language setting/player prefs
« Reply #1 on: August 09, 2012, 08:40:55 PM »
Looks like I might have solved it myself. I save all the player prefs in one global variable named languageSettings. In the language states I put Playerprefs delete all in order to clear out info in languageSettings and then directly after in the same state i put Playerprefs Set int and in that I put the key Swedish for the one that is the swedish state, english as key for the english state and so on and save it in languageSettings variable.

Then in next scene in the FSM that loads the texts, I start by doing 3 Playerprefs has key and set those 3 keys to look for Swedish, English and German. If true send them to the next states which are corresponding to the correct language and fire off the text. It looks like it is working :) Not sure if I should use "int" though or if it is better to use something else.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Saving language setting/player prefs
« Reply #2 on: August 10, 2012, 02:31:09 AM »
Hi,

 There is a game sample that introduces playerprefs management ( for high score):

https://hutonggames.fogbugz.com/default.asp?W890
https://hutonggames.fogbugz.com/default.asp?W895

You seem to have found a solution, so that's good. I would however look into saving one playerprefs with key "lang" and save in it "swedish" or "English" or "German". you don't really need to have a playerpref for each language.

bye,

 Jean