

對於有在 iOS 或是 Android 平台上玩過遊戲的朋友來說,OpenFeint 這個名詞應該不會感到陌生,在 Apple 的 Game Center 出現之前 OpenFeint 早就已經賦予許多遊戲社交平台的功能,像是線上排行榜、遊戲成就、對戰或是討論等等,下面就簡單介 OpenFeint 基本環境設定的方法。
首先來到 OpenFeint developers 開發者官方網站,按下 Sign up 或是 DOWNLOAD THE SDK 進入申請帳號的畫面,畫面如下。

在填妥欄位成功註冊之後,可以點選上方的 Download 來下載 OpenFeint SDK,本範例所下載的版本是 OpenFeint iOS 2.12.2。
接著在 MyOpenFeintSample 資料夾中找到 SDK 中所附的範例檔 MyOpenFeintSample.xcodeproj,這個範例檔包含 OpenFeint 內所有功能的示範,在使用上我們只要將剛剛申請帳號所獲得的 ProductKey 和 Secret 填入,就可以執行本範例檔。
回到網頁,選擇右手邊的 Application Information 選單項目,就可以找到你的 ProductKey 和 Secret,如下圖。

最後,將這兩個項目以字串的型態填入專案中 MyOpenFeintSampleAppDelegate.mm 檔案的程式碼內,程式碼的位置應該不難找,因為預設不是以字串的方式顯示,所以編譯器上會標示錯誤的程式碼區段,程式瑪如下。
[OpenFeint initializeWithProductKey:your_product_key_here
andSecret:your_product_secret_here
andDisplayName:@"LongSampleAppName"
andSettings:settings
andDelegates:delegates];
程式碼到這裡,已經完成 OpenFeint 初步的環境設定,在 SDK 內所提供的範例檔也可以正常執行,如果在執行中出現無法連線 OpenFeint Server 的情形,請確認你的 ProductKey 和 Secret 是否輸入錯誤或是裝置沒有連上 網際網路。
沒有留言:
張貼留言