开发者

display top 10 high scores in cocos2d

开发者 https://www.devze.com 2023-02-14 12:21 出处:网络
am integrated openfeint succesfuly its for global score, i want local top 10 high score d开发者_StackOverflowisplay in cocos2d game

am integrated openfeint succesfuly its for global score, i want local top 10 high score d开发者_StackOverflowisplay in cocos2d game

Anyone has a basic tutorial for this?


Use NSArray to keep the scores. And save/load it using NSUserDefaults

If you have a fixed number of levels - use NSArray to keep. When array values are changed:

-(void) saveScore
{
    NSUserDefaults *settings = [NSUserDefaults standartUserDefaults];
    [settings setObject: myScoreArray forKey:@"my scores"];
    [settings synchronize];
}

To load your array:

-(void) loadScores
{
    NSUserDefaults *settings = [NSUserDefaults standartUserDefaults];
    myScoreArray = [settings objectForKey:@"my scores"];
    //also check if myScoreArray in nil - first launch
}
0

精彩评论

暂无评论...
验证码 换一张
取 消