TextureAtlas问题与libgdx [英] TextureAtlas issue with libgdx
问题描述
我不断收到空指针异常,当我尝试使用TextureAtlass这个libgdx项目。
game.atlas和game.png正在安卓/资产
game.png
大小:1024,1024
格式:RGBA8888
过滤:最近,最近
重复:无
bunny_head
旋转:假的
XY:2,44
尺寸:122,82
原稿:122,82
偏移:0,0
指数:-1
负载寰
TextureAtlas地图集=新TextureAtlas(Gdx.files.internal(game.atlas));
头= atlas.findRegion(bunny_head);
这是我的异常日志
异常螺纹LWJGL应用程序显示java.lang.NullPointerException
在com.fancylancy.game.WorldController.initTestObjects(WorldController.java:49)
在com.fancylancy.game.WorldController.init(WorldController.java:39)
在com.fancylancy.game.WorldController<&初始化GT;(WorldController.java:33)
在com.fancylancy.game.Game.create(Game.java:20)
在com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
在com.badlogic.gdx.backends.lwjgl.LwjglApplication $ 1.run(LwjglApplication.java:120)
你是如何运行你的项目?如果从桌面上的IDE中的,有你记得来设置当前的工作目录是安卓/资产?
如果没有,那么它会找不到game.atlas这可能会导致你看到的问题。
Appologies为BTW张贴这作为一个答案 - 我没有足够的声誉将它张贴作为评论
I keep getting null pointer exceptions when I try and use TextureAtlass with this libgdx project. game.atlas and game.png are under android/assets
game.png
size: 1024,1024
format: RGBA8888
filter: Nearest,Nearest
repeat: none
bunny_head
rotate: false
xy: 2, 44
size: 122, 82
orig: 122, 82
offset: 0, 0
index: -1
Load the atlas with
TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("game.atlas"));
head = atlas.findRegion("bunny_head");
This is my Exception log
Exception in thread "LWJGL Application" java.lang.NullPointerException
at com.fancylancy.game.WorldController.initTestObjects(WorldController.java:49)
at com.fancylancy.game.WorldController.init(WorldController.java:39)
at com.fancylancy.game.WorldController.<init>(WorldController.java:33)
at com.fancylancy.game.Game.create(Game.java:20)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
How are you running your project? If it's from within an IDE on the desktop, have you remembered to set the current working directory to be android/assets?
If not, then it won't find game.atlas which could cause the issue you see.
Appologies for posting this as an answer btw - I don't have enough reputation to post it as a comment.
这篇关于TextureAtlas问题与libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!