这段代码不断抛出io.FileNotFoundException:
spriteBatch = new SpriteBatch();
spriteMap = new Texture(new Pixmap(new FileHandle("Sprites.png")));
spriteMap.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.MipMapLinearNearest);
spriteMap.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
sprites = new TextureRegion(spriteMap).split(16, 16);
有什么想法吗?我也尝试过spriteMap = new Texture(new Pixmap(Gdx.files.internal("Sprites.png")));
但没有运气... Sprites.png恰好在该类所在的包中
使用此方法时:
spriteMap = new Texture(new Pixmap(Gdx.files.internal("Sprites.png")));
完全确保资产文件夹中有一个名为“ Sprites.png”的文件(大写字母“ S”)。
assets/Sprites.png
如果您有一个文件夹,例如数据(默认情况下使用Libgdx-setup-ui创建)。那么您将需要把它放好。
assets/data/Sprites.png
如果您确定文件在那里。然后:
编辑:
您编辑了问题:p
Sprites.png恰好在此类所在的包中
多数民众赞成在您的问题,Gdx.files.internal
进入Android资产文件夹。而不是课程所在的文件夹。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句