相关疑难解决方法(0)

LibGDX没有使用Android资源文件夹

我在编译Android或IOS构建时读取资产文件夹的libGDX项目有问题.在尝试访问android模块下的assets文件夹中的文件时,我似乎总是在IOS或Android中获得FileNotFoundException,但在桌面上运行时却没有.我的桌面配置指向Android资源目录.

执行以下代码时:

 public void readGameMap() throws IOException
    {
        readGameMap("gameMap.txt");
    }

    public void readGameMap(String path) throws IOException
    {

        Scanner s = new Scanner(Gdx.files.internal(path).file());


        int i = 0;


        while ((s.hasNextLine()))
        {

            String str = s.nextLine();

            if (str.length() < maze.length)
                throw new IOException("Incorrect game_map.txt structure");

            for (int j = 0; j < str.length(); j++)
            {

                Object temp;

                switch (str.charAt(j))
                {
                    case '1':
                        temp = new Wall();
                        break;

                    case '3':
                        temp = new Dot();
                        break;

                    default:
                        temp = new Object();
                        break;
                }

                maze[j][i] = …
Run Code Online (Sandbox Code Playgroud)

java android libgdx

1
推荐指数
1
解决办法
1719
查看次数

标签 统计

android ×1

java ×1

libgdx ×1