<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # IOS GameKit ## 簡介 GameKit是iOS SDK中一個常用的框架。其核心功能有3個: * 交互游戲平臺Game Center, * P2P設備通訊功能 * In-Game Voice。 ## 實例步驟 1.在鏈接 iTunes 時請確保擁有一個唯一的 App ID( unique App ID),App ID在我們應用程序更新 bundle ID時及在Xcode代碼簽名與相應的配置文件需要使用到。 2.創建新的應用程序和更新應用程序信息。在添加新的應用程序文檔可以了解更多有關信息。 3.打開你申請的application,點擊Manage Game Center選項。進入后點擊Enable Game Center使你的Game Center生效。接下來設置自己的Leaderboard和Achievements。 4.下一步涉及處理代碼,并為我們的應用程序創建用戶界面。 5.創建一個single view application,并輸入 bundle identifier 。 6.更新 ViewController.xib,如下所示 ![gamekitInterface](https://box.kancloud.cn/2015-12-13_566ce8a7f14d6.jpg) 7.選擇項目文件,然后選擇目標,然后添加GameKit.framework 8.為已添加的按鈕創建IBActions 9.更新ViewController.h文件,如下所示 ``` #import <UIKit/UIKit.h> #import <GameKit/GameKit.h> @interface ViewController : UIViewController <GKLeaderboardViewControllerDelegate> -(IBAction)updateScore:(id)sender; -(IBAction)showLeaderBoard:(id)sender; @end ``` 10.更新ViewController.m ,如下所示 ``` #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; if([GKLocalPlayer localPlayer].authenticated == NO) { [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { NSLog(@"Error%@",error); }]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void) updateScore: (int64_t) score forLeaderboardID: (NSString*) category { GKScore *scoreObj = [[GKScore alloc] initWithCategory:category]; scoreObj.value = score; scoreObj.context = 0; [scoreObj reportScoreWithCompletionHandler:^(NSError *error) { // Completion code can be added here UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Score Updated Succesfully" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [alert show]; }]; } -(IBAction)updateScore:(id)sender{ [self updateScore:200 forLeaderboardID:@"tutorialsPoint"]; } -(IBAction)showLeaderBoard:(id)sender{ GKLeaderboardViewController *leaderboardViewController = [[GKLeaderboardViewController alloc] init]; leaderboardViewController.leaderboardDelegate = self; [self presentModalViewController: leaderboardViewController animated:YES]; } #pragma mark - Gamekit delegates - (void)leaderboardViewControllerDidFinish: (GKLeaderboardViewController *)viewController{ [self dismissModalViewControllerAnimated:YES]; } @end ``` ### 輸出 運行該應用程序,輸出結果如下 ![gamekit_Output1](https://box.kancloud.cn/2015-12-13_566ce8a80d6dc.jpg) 當我們單擊顯示排行榜時,屏幕顯示如下: ![gamekit_Output2](https://box.kancloud.cn/2015-12-13_566ce8a8490a0.jpg) 當我們點擊更新分數,比分將被更新到我們排行榜上,我們會得到一個信息,如下圖所示 ![gamekit_Output3](https://box.kancloud.cn/2015-12-13_566ce8a89db5b.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看