1

我正在使用 libgdx 进行游戏。我想读/写文本文件来更新高分,很简单。我已经在 "$ANDROID-PROJECT/assets/data" 中创建了三个文件,但是当我使用 Gdx.files.local("data/file.txt") 时 Gdx 似乎找不到它们,但是当我使用Gdx.files.internal("data/file.txt")。因为我还需要编写文件,所以我不得不使用 Gdx.files.local。

谁能告诉我当我使用 Gdx.files.local(path) 时 Gdx 在哪里搜索?我应该指定什么路径?

代码:

//for read
FileHandle file = Gdx.files.local("data/scoresCla.txt");

clasico = Float.parseFloat(file.readString());

//for write
FileHandle file = Gdx.files.local("data/scoresCla.txt");

file.writeString(String.valueOf(res), false);
4

1 回答 1

1

如果有人有这个问题,我通过将 Gdx.files.local 更改为 Gdx.files.external 来解决。这样文件存储在 SD 卡中,它具有与本地文件相同的 R/W 文件功能,但在 SD 卡中。

于 2013-01-18T16:38:37.853 回答