2011-10-15 4 views
0

libgdx에 대한 자습서는 this입니다.GdxRuntimeException : 파일을로드 할 수 없습니다.

public class HelloWorld implements ApplicationListener { 
    SpriteBatch spriteBatch; 
    Texture texture; 
    Texture watched_texture; 
    BitmapFont font; 
    Vector2 textPosition = new Vector2(100, 100); 
    Vector2 textDirection = new Vector2(5, 3); 

    @Override 
    public void create() { 
     font = new BitmapFont(); 
     font.setColor(Color.RED); 
     texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); 
     watched_texture = new Texture(Gdx.files.internal("data/wawa.jpg")); 
     spriteBatch = new SpriteBatch(); 
    } 
... 

무엇 내가 얻을하는 응용 프로그램과 "com.badlogic.gdx.utils의 충돌입니다 : 내가 뭘하려고 (사본 wawa.jpg라고합니다) badlogic.jpg의 복사본에서 텍스처를로드 .GdxRuntimeException는 : 디버그 파일 데이터/wawa.jpg "를로드 할 수 없습니다 :

 
10-18 09:24:45.383: WARN/dalvikvm(330): threadid=9: thread exiting with uncaught exception (group=0x40015560) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330): FATAL EXCEPTION: GLThread 10 
10-18 09:24:45.502: ERROR/AndroidRuntime(330): com.badlogic.gdx.utils.GdxRuntimeException: couldn't load file 'wawa.jpg' 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:135) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.graphics.Texture.(Texture.java:126) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.graphics.Texture.(Texture.java:104) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.test.myfirsttriangle.MyFirstTriangle.create(MyFirstTriangle.java:29) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceCreated(AndroidGraphics.java:284) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: data/wawa.jpg (Internal) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:64) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:132) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  ... 6 more 
10-18 09:24:45.502: ERROR/AndroidRuntime(330): Caused by: java.io.FileNotFoundException: data/wawa.jpg 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at android.content.res.AssetManager.openAsset(Native Method) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at android.content.res.AssetManager.open(AssetManager.java:314) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at android.content.res.AssetManager.open(AssetManager.java:288) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:62) 
10-18 09:24:45.502: ERROR/AndroidRuntime(330):  ... 7 more 

그냥 무엇이 잘못되었는지 알아낼 수 없습니다. 나는 또한 동일한 문제를 겪고 안드로이드 프로젝트

+0

답변으로 솔루션을 넣고 그것을를 선택하기 위해 이름을 변경했다. 그러면 사람들이 답변이 필요한 질문을 쉽게 찾을 수 있습니다. http://stackoverflow.com/faq#howtoask를 참조하십시오. (자신의 질문에 완벽하게 대답 할 수 있습니다. :) –

답변

2

해결.

파일의 이름은 gameScreenshot.PNG이며 "gameScreenshot.png"라는 문자열을 넣었습니다.

윈도우에서는 파일 이름 벌금을 인정하지만, 안드로이드에 작동하지 않았다, 그래서 나는 "gameScreenshot.PNG"

+0

한 가지도 만났습니다. 파일 시스템을 통해 에셋 파일을 폴더에 저장하는 경우 eclipse에서 해당 폴더를 새로 고쳐야합니다. – agmcleod

+0

이것은 나를 잡았습니다 - 대신 res/drawable -... 폴더에 넣었습니다 (일반적으로 andorid에있는 이미지의 경우처럼) – jcw

2

의 "자산"폴더에 새로운 질감을 넣지 못했지만, 내 실수는 파일 이름 오류였다

관련 문제