当我尝试将分数发布到Facebook时,我收到此错误:
运行时错误... \ main.lua:22:尝试调用全局'得分'(数字值) 堆栈追溯: [C]:在功能'得分'
我真的不明白为什么它不起作用。 完整的代码是:
local facebook = require ("facebook")
local json = require ("json")
keeping_score = true
score = 1000
keeping_score = true
local scoreText = display.newText( "Score: " .. score, 20, 20,nil, 20)
scoreText:setTextColor(255,255,255)
print("" .. score)
--Facebook function
local faceListener = function (event)
local faceMessage = {
name = "Name",
link = "http://www.site.com",
message = "I just achieved ".. score" playing Name.... download for FREE iPhone & Android at www.site",
caption = "Can you beat my score? ".. score,
description = "Name Full description here, download for FREE iPhone & Android at www.site",
picture = "http://cdn01.androidauthority.com/wp-content/uploads/2011/03/Google-Logo.jpg",
actions = json.encode( { name = "Name", link = "http://www.site.com" } )
}
--Checks for a login and if everything is good then it calls to post the faceMessage.
if event.type == "session" then
if event.phase == "login" then
facebook.request( "me/feed", "POST", faceMessage )
end
end
end
local faceFunc = function ()
facebook.login("appID", faceListener {"publish_stream"} )
end
--Button to activate the post to facebook
local facebutton = display.newRect (0, 0, 50, 50)
facebutton.x = display.contentWidth/2; facebutton.y = display.contentHeight/2
facebutton:addEventListener("tap", faceFunc)
任何解决方案?
答案 0 :(得分:3)
message = "I just achieved ".. score" playing Name.... download for FREE iPhone & Android at www.site",
错过score
后的连接
答案 1 :(得分:0)
message =“我刚刚实现了”..分数......“玩名字....下载免费iPhone和Android网站www.site”,