私のゲームがゲーム センターに表示されません。これを一日中解決しようとしています。オブジェクト キー「score」を含む文字列をリーダー ボードに保存したいと考えています。非常に明白な何かが欠けているに違いありませんが、わかりません。お邪魔して申し訳ありませんが、これは私を怒らせるだけです笑。バンドルIDはmoocowcurtisで、info.plistに入れました
gamecentermanager.h
#import <Foundation/Foundation.h>
@class GKLeaderboard, GKAchievement, GKPlayer;
@protocol GameCenterManagerDelegate <NSObject>
@optional
- (void) processGameCenterAuth: (NSError*) error;
- (void) scoreReported: (NSError*) error;
- (void) reloadScoresComplete: (GKLeaderboard*) leaderBoard error: (NSError*) error;
- (void) achievementSubmitted: (GKAchievement*) ach error:(NSError*) error;
- (void) achievementResetResult: (NSError*) error;
- (void) mappedPlayerIDToPlayer: (GKPlayer*) player error: (NSError*) error;
@end
@interface GameCenterManager : NSObject
{
NSMutableDictionary* earnedAchievementCache;
id <GameCenterManagerDelegate, NSObject> delegate;
}
//This property must be attomic to ensure that the cache is always in a viable state...
@property (retain) NSMutableDictionary* earnedAchievementCache;
@property (nonatomic, assign) id <GameCenterManagerDelegate> delegate;
+ (BOOL) isGameCenterAvailable;
- (void) authenticateLocalUser;
- (void) reportScore: (int64_t) score forCategory: (NSString*) category;
- (void) reloadHighScoresForCategory: (NSString*) category;
- (void) submitAchievement: (NSString*) identifier percentComplete: (double) percentComplete;
- (void) resetAchievements;
- (void) mapPlayerIDtoPlayer: (NSString*) playerID;
@end
Leaderboard.m ファイル
#import "leaderboard.h"
#import "GameCenterManager.h"
@implementation leaderboard
-(id) init
{
[[GameCenterManager sharedGameCenterObject] reportScore:score forCategory: kLeaderboardID];
int highScore = [[[NSUserDefaults standardUserDefaults] objectForKey:@"score"] intValue];
return self;
}
-(void)displayLeaderboard
{
GKLeaderboardViewController *leaderboardViewController = [[GKLeaderboardViewController alloc] init];
leaderboardViewController.leaderboardDelegate = self;
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[app.navController presentModalViewController:leaderboardViewController animated:YES];
}
#pragma mark GameKit delegate
-(void) achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[app.navController dismissModalViewControllerAnimated:YES];
}
-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[app.navController dismissModalViewControllerAnimated:YES];
}
// on "dealloc" you need to release all your retained objects
- (void) dealloc
{ [super dealloc];
}
@end
リーダーボード.h
#import "GameCenterManager.h"
@interface leaderboard: CCLayer<GKLeaderboardViewControllerDelegate>
@end
GameCenterManager.h
#import <Foundation/Foundation.h>
@class GKLeaderboard, GKAchievement, GKPlayer;
@protocol GameCenterManagerDelegate <NSObject>
@optional
- (void) processGameCenterAuth: (NSError*) error;
- (void) scoreReported: (NSError*) error;
- (void) reloadScoresComplete: (GKLeaderboard*) leaderBoard error: (NSError*) error;
- (void) achievementSubmitted: (GKAchievement*) ach error:(NSError*) error;
- (void) achievementResetResult: (NSError*) error;
- (void) mappedPlayerIDToPlayer: (GKPlayer*) player error: (NSError*) error;
@end
@interface GameCenterManager : NSObject
{
NSMutableDictionary* earnedAchievementCache;
id <GameCenterManagerDelegate, NSObject> delegate;
}
//This property must be attomic to ensure that the cache is always in a viable state...
@property (retain) NSMutableDictionary* earnedAchievementCache;
@property (nonatomic, assign) id <GameCenterManagerDelegate> delegate;
+ (BOOL) isGameCenterAvailable;
- (void) authenticateLocalUser;
- (void) reportScore: (score) forCategory: (NSString*) category;
- (void) reloadHighScoresForCategory: (NSString*) category;
- (void) submitAchievement: (NSString*) identifier percentComplete: (double) percentComplete;
- (void) resetAchievements;
- (void) mapPlayerIDtoPlayer: (NSString*) playerID;
@end
AppSpecificValues.h
#define kEasyLeaderboardID @"com.appledts.EasyTapList"
#define kHardLeaderboardID @"com.appledts.HardTapList"
#define kAwesomeLeaderboardID @"moocowcurtis"