Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 46

jasonr
Aspiring developer
Profile
Posts: 45
Reg: Jan 14, 2013
California, USA
2,750
02/19/13 11:34 AM (12 years ago)

save score [solved]

What's the easiest/quickest way to save a score? I am using the quiz plugin and would like to keep track of the highest score. I'd rather not go the route of sending the data to a site for storage, but would rather store the values locally.
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
02/19/13 03:42 PM (12 years ago)
In the iOS source code, there are some methods built in for getting and setting NSUserDefaults. That would be the quickest/easiest way, but would require a little bit of coding. Not sure about Android...
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
02/19/13 04:44 PM (12 years ago)
You could use Game Center. Jake
 
jasonr
Aspiring developer
Profile
Posts: 45
Reg: Jan 14, 2013
California, USA
2,750
like
02/20/13 06:22 AM (12 years ago)
"In the iOS source code, there are some methods built in for getting and setting NSUserDefaults. That would be the quickest/easiest way, but would require a little bit of coding. " Thanks, I'll give it a shot!
 
jasonr
Aspiring developer
Profile
Posts: 45
Reg: Jan 14, 2013
California, USA
2,750
like
02/20/13 06:38 AM (12 years ago)
OK, that was too easy. Others might want to know this, so here is my solution. (Thanks Stobe!) I'm using the quiz plugin, so in the quizEnded method I pasted this at the top: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; int highScore = [defaults integerForKey:@"highScore"]; did my highScore calculation in the middle then at the end of the method: [defaults setInteger:highScore forKey:@"highScore"];
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/20/13 01:17 PM (12 years ago)
Cool! Thanks! Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.