com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件: - 错误 [英] com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: - Error

查看:568
本文介绍了com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件: - 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在iOS的libGDX中开发一个应用程序。

I am trying to develop an application in libGDX for iOS.

在我的Java课程中,我写了这一行

In my Java class I have written this line

private Texture texture = new Texture(Gdx.files.internal("data/folder_name_1/folder_name_2/abcd.png"));

我的robovm.xml看起来像这样 -

and my robovm.xml looks like this-

<iosInfoPList>Info.plist.xml</iosInfoPList>
  <resources>
    <resource>
      <directory>../android/assets</directory>
      <includes>
        <include>**</include>
      </includes>
      <skipPngCrush>true</skipPngCrush>
    </resource>
    <resource>
      <directory>data</directory>
    </resource>
  </resources>

当我尝试在iOS模拟器上运行代码时,运行正常。但是当我尝试在iOS设备(即iPhone)上运行它时。它会生成一个看起来像这样的错误 -

When I try to run the code on iOS simulator it runs fine. But when I try to run it on an iOS device i.e. iPhone. It generates an error which looks like this-

com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/folder_name_1/folder_name_2/abcd.png

有人可以帮我吗?

注意: - 在我的数据文件夹中的iOS项目中,还有另一个'data'文件夹,其中有另一个名为'folder_name_1'的文件夹,然后在其中我有'folder_name_2'文件夹并在里面它我的png文件'abcd.png'。

Note:- in my iOS project in the data folder, there is another 'data' folder in which there is another folder named 'folder_name_1', then inside it I have 'folder_name_2' folder and inside it I have my png file 'abcd.png'.

推荐答案

你面前的错误就在你面前.. 。

You've got the error right in front of you...

 <directory>../android/assets</directory>

您要查找的资源不在data文件夹中。它位于android项目中的Assets中。

the resource you are looking for is NOT in the "data" folder. It's in the "Assets" which is in the android project.

同样在加载纹理时,您不需要使用FileHandler ..这就足够了:

Also when loading textures you don't need to use a FileHandler.. This would be enough:

texture = new Texture("image.png");

这将是android项目的根(资产)文件夹

which would be the root (assets) folder of the android project

这篇关于com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件: - 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆