TmxMapLoader使用打包的tileset [英] TmxMapLoader to use packed tileset

查看:168
本文介绍了TmxMapLoader使用打包的tileset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧的libgdx地图api中,他们曾经拥有

In the old libgdx map api, they used to have

map = TiledLoader.createMap(Gdx.files.internal("maps/testmap.tmx"));
atlas = new TileAtlas(map, Gdx.files.internal("maps"));
tileMapRenderer = new TileMapRenderer(map, atlas, 8, 8); 

但是,在新的libgdx中,规则发生了变化,不再需要先使用地图打包工具来加载图块地图.您可以将.tmx文件直接与tileet png一起使用.这样的操作会起作用,然后调用render.

However in the new libgdx the rule changes, to load a tilemap there is no longer needed to use map packer first. You can directly use the .tmx file with the tileset png. Something like following will work, and then call render.

TiledMap map = new TmxMapLoader().load("maps/testmap.tmx");

我的问题是用于生成.tmx文件的原始tileelt.png,它的大小不是2的幂.因此,我仍然必须使用Texture Packer或Map Packer对其进行打包以供使用.

My question is the original tileselt.png that used to generate the .tmx file, it's size is not power of two. So I still have to either use Texture packer or a map packer to pack it for using.

我无法成功将打包文件与.tmx关联;

I could not successfully associate the packed file with the .tmx;

总有办法解决这个问题吗?

Is there anyway to approach this issue?

谢谢

推荐答案

如果您的目标是GLES 1.0,则需要2的幂幂.某些设备可能允许使用GLES 1.0进行非二次幂运算,但这不能保证.使用GLES 2.0可以解除此限制,但是您仍然可以通过二次幂获得更好的性能.

If you target GLES 1.0, you will need power-of-two tilesets. Some devices might allow non-power-of-two with GLES 1.0, but that isn't guaranteed. With GLES 2.0 this restriction is lifted, but you still might get better performance out of power-of-two.

您仍然可以使用TiledMapPacker生成的地图,只需使用AtlasTmxMapLoader而不是TmxMapLoader加载地图即可.

You can still use the TiledMapPacker-produced maps, you will just need to load the map with AtlasTmxMapLoader instead of TmxMapLoader.

这篇关于TmxMapLoader使用打包的tileset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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