リーダーボード付けてリジェクト2.3
- 2011.07.30 Saturday
- Xcode4覚書
- 09:40
- comments(0)
- trackbacks(0)
- -
- -
- by Sige
- (void) authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer authenticateWithCompletionHandler:^(NSError *error) {
if (localPlayer.isAuthenticated)
{
// 認証済みプレーヤーの追加タスクを実行する
}
}];
}
- (void) reportScore: (int64_t) score_gc forCategory: (NSString*) category
{
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category]
autorelease];
scoreReporter.value = score_gc;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
// 報告エラーの処理
UIAlertView *alert = [[UIAlertView alloc] init];
alert.delegate = self;
alert.title = @"スコアの送信に失敗しました";
alert.message = @"もう一度送信しますか?";
[alert addButtonWithTitle:@"はい"];
[alert addButtonWithTitle:@"いいえ"];
[alert show];
}
}];
}
// アラートのボタンが押された時に呼ばれる
-(void)alertView:(UIAlertView*)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
[self reportScore:score forCategory:@"hogehoge"];
break;
case 1:
break;
}
}
- (IBAction) showLeaderboard
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController: leaderboardController animated: YES];
}
}
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController {
[self dismissModalViewControllerAnimated:YES];
}
btn = [UIButton buttonWithType:111];
btn.frame = CGRectMake(18.0f, 264.0f, 65.0f, 65.0f);
[btn setTitle:[NSString stringWithUTF8String:""] forState:UIControlStateNormal];
[btn setValue:[UIColor yellowColor] forKey:@"tintColor"];
[self.view addSubview:btn];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; // 徐々に減速
// アニメ処理
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; // 徐々に加速
// アニメ処理
[UIView commitAnimations];
[UIView setAnimationDuration:0.01];
[UIView setAnimationCurve:UIViewAnimationCurveLinear]; // 等速アニメ
[UIView commitAnimations];