我有一个系统的高分,这要求你输入你的名字,它将你的分数保存到一个文本文件中。当再次将比分按钮被按下时,显示所有的高分这个文本文件将被打开。眼下,当按下按键分,它只是一个空白窗口答案。该文件Scores.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
这里是节省了分数scores.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
在stopGame你已经错过了斜杠“/”它应该是一样的,你在鼠标松开了:
put specialFolderPath("Documents") & "/Scores.txt" into myFile
祝好运!