我有一个高分系统,它要求你输入你的名字,它会把你的分数保存到一个文本文件中。然后,当按下分数按钮时,此文本文件将再次打开,显示所有高分。现在,当按下分数按钮时,它只会以空白窗口回答。文件分数.txt确实保存了所有分数。以下是分数按钮的文本:
on mouseUp
put specialFolderPath("documents") & "/Scores.txt" into myFile
set itemDelimiter to tab
put url ("file:" & myFile) into x
sort lines of x numeric descending by item 2 of each
answer x
end mouseUp
以下是将分数保存到分数的代码.txt:
on stopGame
put false into gameisRunning
set the bottom of btn "bird" to 225
set the angle of image "Bird" of stack "graphics" to 0
ask "What is your name?"
if it is not empty then
put it into theName
put specialFolderPath("Documents") & "Scores.txt" into myFile
put URL("file:" & myFile) into highScores
put theName & tab & field "score" & return after highScores
put highScores into URL ( "File:" & myFile)
end if
end stopGame
在停止游戏中,您错过了斜杠"/",它应该与您在mouseUp中的斜杠相同:
put specialFolderPath("Documents") & "/Scores.txt" into myFile
祝你好运!