当我将updateScore函数放入电晕时获取和出错

时间:2013-07-22 14:18:22

标签: android lua corona

我在这里得到一个错误是链接http://cdn.imghack.se/images/b902d2e1eea1f477e1a649f6004f34f3.png,当我把它放在我的代码中时,我正在使用导演类我有错误

        local path = system.pathForFile( "myfile.txt", system.DocumentsDirectory )
        local file = io.open( path, "w+" )
        local reader, er = io.open( path, "r" )
        local contents = reader:read("*n")

                local function update( event )
                updateBackgrounds()
                updateSpeed()
                updateMonster()
                updateBlocks()
                updateBlasts()
                updateSpikes()
                updateGhosts()
                checkCollisions()
                updateScore()
                end


            function updateScore()

                        if (stopscore == false) then
                                score = score + 1
                                scoreText.text = "score: " .. score
                                scoreText:setReferencePoint(display.CenterLeftReferencePoint)
                                scoreText.x = 0
                                scoreText.y = 30
                                print (er)
                        else
                                if(  contents == nil ) then 
                                        file:write(score)   
                                        file:close()
                                        reader:close()  

                                else
                                        file:close()
                                        reader:close()
                                end

                                 if ( contents < score and monster.isAlive == false)
                                        file:write(score)   
                                        file:close()
                                        reader:close()
                                else
                                        file:close()
                                        reader:close()
                                end


                        end     
             end
有人能帮帮我吗?仍然发布相同的错误

1 个答案:

答案 0 :(得分:0)

您遇到语法错误,请检查:

   function updateScore()

                if (stopscore == false) then
                        score = score + 1
                        scoreText.text = "score: " .. score
                        scoreText:setReferencePoint(display.CenterLeftReferencePoint)
                        scoreText.x = 0
                        scoreText.y = 30
                else
                        if( contents < score and monster.isAlive == false) then  
                                file:write(score)   
                                file:close()
                                reader:close()                            
                        else
                                file:close()
                                reader:close()
                        end
                end     
     end