0

我正在尝试制作一个评分系统,显示每个场景的所有时间得分,当用户完成一个场景时,该场景的得分被添加到所有时间得分中。

我在编译器中遇到 1 个错误:尝试对字段“分数”执行“算术”

来自主 lua 的代码:不包含错误,但不确定是否正确。 -- 1 Clue 1 Word

display.setStatusBar (display.HiddenStatusBar)

local storyboard = require ( "storyboard" )
storyboard.gotoScene("menu") 

storyboard.state = {}
storyboard.state.score = 0
storyboard.state.score = display.newText(storyboard.state.score, 250, 20, "ARIAL", 16)

<code>

The error appears in the line: storyboard.state.score = storyboard.state.score + 1

<code>
if(correct == #L1) then
    --alert()
    print ("CORRECT "..#L1)
    line.isVisible = false
    storyboard.gotoScene( "scene2", "slideLeft", 500)
    storyboard.state.score = storyboard.state.score + 1
    storyboard.removeScene( "scene1" )
end


end

结尾

4

1 回答 1

1

为什么要storyboard.state.score分配两次?

storyboard.state.score = 0
storyboard.state.score = display.newText(storyboard.state.score, 250, 20, "ARIAL", 16)

更新:

storyboard.state = {score = 0}
score = display.newText(storyboard.state.score, 250, 20, "ARIAL", 16) 

storyboard.gotoScene( "scene2", "slideLeft", 500) 
storyboard.state.score = storyboard.state.score + 1 
storyboard.removeScene( "scene1" ) 
于 2013-04-19T12:09:52.060 回答