[英]Hide score file in java game
I made a Java game and it records the high scores in a .dat
file, then I converted the game into an .exe
file. 我制作了一个Java游戏,它在.dat
文件中记录了高分,然后将游戏转换为.exe
文件。 However, when I play the .exe
file and it records the score, the highscores.dat
appears in whatever directory the .exe
is located. 但是,当我播放.exe
文件并记录分数时, highscores.dat
出现在.exe
所在的任何目录中。 I'm not very familiar with files processing in java aside from creating and reading them using the basic input streams and output streams. 除了使用基本输入流和输出流创建和读取文件外,我对Java中的文件处理不是很熟悉。 Is there any way to hide the score file so that if I give the game to someone the highscores.dat
won't appear in their computer? 有什么方法可以隐藏分数文件,以便如果我将游戏交给某人, highscores.dat
不会出现在他们的计算机中?
On Windows you could store your file in the %appdata%/<gamename>/highscores.dat
directory without admin persmissions. 在Windows上,您可以将文件存储在%appdata%/<gamename>/highscores.dat
目录中,而无需管理员权限。
On Linux you could chose for the directory ~/.<gamename>/highscores.dat
在Linux上,您可以选择目录~/.<gamename>/highscores.dat
On Mac OSX you could chose the directory /Users/<USERNAME>/Library/Application Support/<gamename>/highscores.dat
在Mac OSX上,您可以选择目录/Users/<USERNAME>/Library/Application Support/<gamename>/highscores.dat
If you do it like this, the file wont be showing up on your games' folder. 如果您这样做,文件将不会显示在游戏的文件夹中。 This has also the advantage of maintaining the highscores data, even when you move your game to another location. 即使将游戏移到另一个位置,这也具有保持高分数据的优势。
可能您可以使用任何加密技术,然后将其写入乐谱文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.