• 这个API是实验性的,并且会变化,因为OpenFient目前也在完善中,而Apple Game Center最近也将发布。
• 在当前的alpha版本,只支持iOS,因为OpenFient暂不支持Android。
• 没有模拟器可以支持这个特性,因为 OpenFeint 对MacOS也不可用。
Corona使用OpenFeint的2.7.2版本。
例如基本的 OpenFeint 整合,参看 “OpenFeint landscape” 和 “OpenFeint portrait”范例工程(只能构建为iPhone或iPad应用)
OpenFeint API
这一行使得 “openfeint”名字空间下, OpenFeint特性可用。
openfeint = require "openfeint"
openfeint.init( "
用指定的产品key,密钥和显示名来初始化一个app。这应该只能被调用一次,越早调用越好。
openfeint.launchDashboard()
启动 OpenFeint 小窗口(dashboard)。
openfeint.launchDashboard("leaderboards")
打开用户的排行榜小窗口(dashboard)。
openfeint.launchDashboard("challenges")
打开用户的挑战小窗口。
openfeint.launchDashboard("achievements")
打开用户的成就小窗口。
openfeint.launchDashboard("friends")
打开用户好友小窗口。
openfeint.launchDashboard("playing")
打开用户的游戏小窗口。
openfeint.launchDashboard("highscore")
打开用户的高分小窗口。
openfeint.launchDashboardWithListLeaderboardsPage()
已过时.请使用 openfeint.launchDashboard("leaderboards").
openfeint.launchDashboardWithChallengesPage()
已过时.请使用 openfeint.launchDashboard("challenges")
openfeint.launchDashboardWithAchievementsPage()
已过时.请使用 openfeint.launchDashboard("achievements")
openfeint.launchDashboardWithFindFriendsPage()
已过时.请使用 openfeint.launchDashboard("friends")
openfeint.launchDashboardWithWhosPlayingPage()
已过时.请使用 openfeint.launchDashboard("playing")
openfeint.unlockAchievement( achievementId )
解锁指定的成就。
openfeint.setHighScore( { leaderboardID=ID, score=highScore [, displayText=displayString] } )
设置用户的高分。你可以可选地指定一个文本字符串,在OpenFeint小窗口上实际数字高分的位置显示。
这个函数接收一个table作为参数,这个table包含下面的元素:
• leaderboardID: 字符串。 高分应该被提交的OpenFeint排行榜的ID。
• score: 数值。这个新的高分值被提交到指定的排行榜上。
• displayText: 字符串。一个可选的字符串参数,在分数数字的位置显示score参数的值。
下面是一个使用 setHighScore 的例子:
openfeint.setHighScore( { leaderboardID="abc123", score=82342, displayText="82,342 pts" } )
openfeint.setHighScore( leaderboardId, score )
已经过时。应该改用上面提到的setHighScore的参数方式。
网络存储卡
通过使用OpenFient的“网络存储卡”,你现在可以存储任意游戏数据:
local downloadListener = function(event)
print(event.name .. " => '" .. event.blob .. "' downloaded")
return true
end
openfeint.uploadBlob( blobKey, "some blob data" )
openfeint.downloadBlob( blobKey, downloadListener )
blobKey是一个用来识别什么数据要存储的字符串键。这个 blob数据,是长度在OpenFient允许内的任意字符串。
当下载完成时, download listener将被调用。如果 blob的长度为0,那么下载就不会成功。