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]