2014-04-28 110 views
0

快速問題 - 我希望爲我創建的彈球遊戲創建一個離線高分數系統,它將10個最高分存儲在文本文檔中。我不知道如何做到這一點 - 所以任何幫助都非常感謝 - 我使用閃存AS3,如果可能的話,請將答案作爲基本理解,因爲在這個特定時刻,我仍然在Flash中進行非常基本的編程,從閃存保存文本文件

我目前還沒有嘗試任何事情,因爲我不知道從哪裏開始...

感謝,
薩姆。

+0

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/package-detail.html – philipp

回答

0

爲了寫入文本文件(對您的文件系統具有寫入權限),您需要將項目發佈爲AIR應用程序。我建議你改用SharedObject類來存儲你的數據。例如,您可以輕鬆地讀取和寫入數組,因此不需要解析。

 var scores : Array  = new Array(10,20,30); 
     var my_so : SharedObject = SharedObject.getLocal("myGameHighscore"); 
     my_so.data.scores   = scores; // set scores var to data object of SharedObject 
     my_so.flush();   // writes the data instantly 

     // To retreive your scores simply use getLocal again and then do something like: 
     trace(my_so.data.scores[0]); // will trace first element of scores array "10" 

參考http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html

+0

謝謝:)幫了我很多 – SamCale