Game Center... Open Feint

Hi, hope somebody might be able to offer some advice.

I have Open Feint integrated in my app, which is designed for both IoS and Android.

If I only want Game Center for IoS users I presume I have to go through Open Feint, if I wish to keep Open Feint available to Android users?

I’ve yet to setup leaderboards, achievements, etc… on Itunes Connect, but am I right in assuming that I have to finish creating my app profile (screens, pricing, etc…) in ITC before I can get Game Center up and running.

I’ve yet to make decisions regarding things like this and don’t have finalised screenshots, but it seems iTunes Connect is insisting I upload all of this before I can manage Game Center options.

Any help would be extremely grateful… [import]uid: 33275 topic_id: 23304 reply_id: 323304[/import]

Damn forgot a few things I wanted to ask :slight_smile:

I imagine if I want to keep a central code base I’m going to have to have to branch the code depending on what device the user is on? i.e do Game Center stuff if user is on IoS otherwise do Open Feint stuff?

[import]uid: 33275 topic_id: 23304 reply_id: 93318[/import]

Damn forgot a few things I wanted to ask :slight_smile:

I imagine if I want to keep a central code base I’m going to have to have to branch the code depending on what device the user is on? i.e do Game Center stuff if user is on IoS otherwise do Open Feint stuff?

[import]uid: 33275 topic_id: 23304 reply_id: 93319[/import]

The best way to do this is to abstract the gameNetwork api.

So for example make a new file called gaming.lua (or whatever you’d like to call it). Then create a local boolean for what platform you’re on. Then require gameNetwork only in that file, and implement each of the methods you want to use (initialize, submit scores, unlock achievements).

Then in each of those methods have a case for game center and a case for openfeint. Now in your project, require gaming wherever you want to do some action involving gameNetwork.

Then to set a high score for example, you’d do gaming.submitScore(leaderboardId, score)

and then function would look roughly like this in gaming.lua:

local gaming = {}  
  
...  
  
function gaming.submitScore(leaderboard, score)  
 if (iOS) then  
 --Game Center  
 gameNetwork.request("setHighScore", {localPlayerScore={category=leaderboard, value=score}})  
 else  
 -- OpenFeint  
 gameNetwork.request("setHighScore", {leaderboardID=leaderboardOF[leaderboard], score=score, displayText=score.." pts"})  
 end  
end  
  
...  
  
return gaming  

Where leaderboardOF is a table of keys for each of your GC leaderboard id’s with the value stored as the associated string of numbers for OpenFeint. [import]uid: 87138 topic_id: 23304 reply_id: 93323[/import]

Actually its a bit easier. You just have to add conditional code to your app.
I set up a variable (global if your using Director, added to the storyboard table if your using storyboard)

-- Director  
\_G.isAndroid = false  
if system.getInfo("platformName") == "Android" then  
 \_G.isAndroid = true  
end  
  
-- storyboard  
  
local storyboard = require("storyboard")  
storyboard.isAndroid = false  
if system.getInfo("platformName") == "Android" then  
 storyboard.isAndroid = true  
end  

NOTE: I’ll be using the storyboard version for the rest of this!

Then later when you want to init gameNetwork:

if storyboard.isAndroid then  
 local gameNetworkKey = "your OF Network Key"  
 local gameNetworkSecret = "your OF network secret"  
 local gameNetworkAppId = "123456" -- your OF appID  
 gameNetwork.init( "openfeint", gameNetworkKey, gameNetworkSecret, "Your Super Cool Game Name", gameNetworkAppId )  
else  
 gameNetwork.init("gamecenter", gcLoginCallback)  
end  

Of course for GC you need to code up that call back function and so on (beyond the scope of this post).

Later when you want to set a score:

if storyboard.isAndroid then  
 -- Openfeint  
 gameNetwork.request( "setHighScore", { leaderboardID="youreLeaderboardID", score=myScore, displayText=myScore } )  
else  
 gameNetwork.request("setHighScore", {  
 localPlayerScore = {  
 category="highscores",   
 value=tonumber(myScore)   
 },  
 listener=postScoreSubmit})  
end  

Of course in the example above “category” is whatever you told iTunes Connect your leaderboard name is and you have to write the code for the postScoreSubmit() function.

This way you only have one set of code and it’s smart as to the platform which makes it easier for you to maintain in the end.
[import]uid: 19626 topic_id: 23304 reply_id: 93325[/import]

Hi guys,

Really appreciate all of your help. Just one question at the moment - I realise that I’ve got to set my game up in iTunes Connect, however it’s asking for a lot of information that I don’t have ready at the moment.

Things like release date, price, finished screenshots, icon, etc… do I really have to enter all of this before I can start setting up Game Center on my game?

Many thanks, [import]uid: 33275 topic_id: 23304 reply_id: 95206[/import]