ゲームセンターにオフラインで使えるキャッシング機構はありますか?ゲームセンターがオフラインモードでスコアを収集し、ネットワークステータスがオンラインに変更されたときにスコアをサーバーに配信することは可能ですか? ダウンロードした楽譜をオフラインで読むことはできますか?
上記の質問の答えが NO の場合、これを実行できるライブラリはありますか?
助けてくれてありがとう。
ゲームセンターにオフラインで使えるキャッシング機構はありますか?ゲームセンターがオフラインモードでスコアを収集し、ネットワークステータスがオンラインに変更されたときにスコアをサーバーに配信することは可能ですか? ダウンロードした楽譜をオフラインで読むことはできますか?
上記の質問の答えが NO の場合、これを実行できるライブラリはありますか?
助けてくれてありがとう。
Axeva の回答は正しくありません。GKLocalPlayerは「resubmitStoredScores」などのメソッドを定義していません。むしろ、このメソッドは、GameKit リーダーボードの使用を示す Apple の iOS Developer Library で提供されるサンプル コードで定義および実装されています。
Apple の例からコードをコピーしたくない場合は、いくつかのライブラリがあります。いくつかのグーグルは、github.com で次のヒットを見つけました。
これらのいずれもニーズを満たさない場合は、独自のソリューションを実装する必要があります。
はい、Game Center はスコアをキャッシュします。アプリ デリゲートの didFinishLaunchingWithOptions で呼び出す GKLocalPlayer オブジェクトの resubmitStoredScores メソッドがあります。
次に例を示します。
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if (localPlayer.isAuthenticated) {
// Enable Game Center Functionality
self.gameCenterAuthenticationComplete = YES;
if (! self.currentPlayerID || ! [self.currentPlayerID isEqualToString: localPlayer.playerID]) {
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: kGameInProgress];
// Switching Users
if (!self.player || ![self.currentPlayerID isEqualToString: localPlayer.playerID]) {
// If there is an existing player, replace the existing PlayerModel object with a
// new object, and use it to load the new player's saved achievements.
// It is not necessary for the previous PlayerModel object to writes its data first;
// It automatically saves the changes whenever its list of stored
// achievements changes.
self.player = [[[PlayerModel alloc] init] autorelease];
}
[[self player] loadStoredScores];
[[self player] resubmitStoredScores];
}
} else {
// User has logged out of Game Center or can not login to Game Center, your app should run
// without GameCenter support or user interface.
self.gameCenterAuthenticationComplete = NO;
}
}];