0

当我尝试将分数发布到 facebook 时,我收到此错误:

运行时错误 ...\main.lua:22: 尝试调用全局 'score' (一个数值) 堆栈回溯: [C]: in function 'score'

而且我真的不明白为什么它不起作用。完整的代码是:

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)

有什么解决办法吗?

4

2 回答 2

3
message = "I just achieved ".. score"  playing Name.... download for FREE iPhone & Android at www.site",

score错过后的串联

于 2013-02-25T21:00:45.233 回答
0

message = "我刚刚达到 ".. score .." 播放 Name.. 在 www.site 免费下载 iPhone 和 Android",

于 2013-07-09T00:17:39.160 回答