0

我在这里遇到错误是链接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

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

4

1 回答 1

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
于 2013-07-22T14:21:59.437 回答