我正在使用twitter API发布高分,并且似乎正确收集了score变量,但是在他们玩的回合中没有获得高分值。
示例:我第一次开始游戏,我的最高分是0。游戏结束时我获得20分,并想发布它,但我的推文显示为0。在下一个游戏中显示20。
因此,它基本上每次落后1转,并显示以前的高分。我感觉到它是一个基本错误,但我看不到,可以解决它。
我有两个文件可保存排行榜等的得分。
local scoring = require("helpers.scoring")
local utils = require("helpers.globals")
function scene:createScene( event )
local group = self.view
utils.loadHighscoreInfo()
- 游戏结束 -
if miles > utils.highscore then
utils.highscore = miles
utils.saveHighscoreInfo()
scoring.setHighScore( utils.highscore, utils.leaderboard )
end
-Twitter设置-
local options = {
message = " I scored " .. utils.highscore .. " Miles ",
listener = tweetCallback
}
function tweetCallback( event )
if ( event.action == "cancelled" ) then
print( "User cancelled" )
else
native.showPopup( "twitter", options )
print( "Thanks for the tweet!" )
end
end
在处理鸣叫之前,请更新选项消息。
local options = {
message = " I scored " .. utils.highscore .. " Miles ",
listener = tweetCallback
}
它不会随着utils.highscore的变化而动态更新,而是在您声明该值时拍摄该值的快照(首先运行每个游戏)。因此,您只需要在游戏结束使用后对其进行更新
options.message = "I scored" .. utils.highscore .. " Miles "
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句