简体   繁体   中英

Is it possible to remove points or acheivements from Game Center?

是否可以根据应用中的内容减少用户在游戏中心的积分?

Straight from the GameKit Programming Guide

- (void) resetAchievements
{
    // Clear all locally saved achievement objects.
    achievementsDictionary = [[NSMutableDictionary alloc] init];
    // Clear all progress saved on Game Center
    [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error)
    {
        if (error != nil)
        //handle errors
    }];
}

I don't think it's possible to remove scores though.

The solution by James Webster is correct, I only add the following more complete solution for future reference.

For dev I use the following in my App Delegate's application:didFinishLaunchingWithOptions:

//Comment next line to prevent resetting of achievements
#define RESETACHIEVEMENTS

#if defined RESETACHIEVEMENTS
#warning RESETACHIEVEMENTS is enabled!
    // Log in to GameCentre
    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) 
     {
        if (error) {
            //Handle error
        } else {
            // Reset achievements
            [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error)
             {
                if (error) {
                    //Handle error
                }
             }];
        }
     }];
#endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM