简体   繁体   English

libgdx:平铺地图在使用多个图块集时渲染不正确

[英]libgdx: tiled map renders incorrectly when using multiple tilesets

I've been starting to work with libGDX to load tmx maps made using Tiled and have a weird issue where as soon as I use a second tileset my program stops displaying the map correctly, either showing nothing at all or using totally different tiles.我已经开始使用 libGDX 来加载使用 Tiled 制作的 tmx 地图,并且有一个奇怪的问题,一旦我使用第二个图块集,我的程序就会停止正确显示地图,要么根本不显示,要么使用完全不同的图块。 This occurs even if no tiles from the other tileset are used, just having a second tileset tags screws it up.即使没有使用其他tileset中的tile,也会发生这种情况,只需使用第二个tileset标签即可。 Everything still looks fine when opening it in Tiled and I'm not familiar enough with the tmx format to know if it's the renderer or the data that's messed up.在 Tiled 中打开它时,一切看起来仍然很好,而且我对 tmx 格式不够熟悉,无法知道是渲染器还是数据搞砸了。 The libGDX code I'm using is identical to the tutorial below but using different tilesets (both of which I've been able to render properly alone), although I've also tried other variations of the rendering code without any luck .我使用的 libGDX 代码与下面的教程相同,但使用了不同的图块集(这两个我都能够单独正确渲染),尽管我也尝试了渲染代码的其他变体,但没有任何运气。

https://www.gamefromscratch.com/post/2014/04/16/LibGDX-Tutorial-11-Tiled-Maps-Part-1-Simple-Orthogonal-Maps.aspx https://www.gamefromscratch.com/post/2014/04/16/LibGDX-Tutorial-11-Tiled-Maps-Part-1-Simple-Orthogonal-Maps.aspx

Map in Tiled平铺地图

在此处输入图片说明

What I see running my program我看到运行我的程序

在此处输入图片说明

The tmx file: .tmx 文件:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.3.1" orientation="orthogonal" renderorder="right-down" compressionlevel="-1" width="32" height="32" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="1">
  <tileset firstgid="1" source="sprites.tsx"/>
  <tileset firstgid="1025" source="tileset.tsx"/>
  <layer id="1" name="Tile Layer 1" width="32" height="32">
    <data encoding="base64">
    KgQAACoEAAAqBAAAKgQAACoEAAAqBAAAKgQAACoEAAAqBAAAKg...
    </data>
  </layer>
  <layer id="2" name="Tile Layer 2" width="32" height="32">
    <data encoding="base64">
    iQAAAMEBAADBAQAAwQEAAMEBAADBAQAAwQEAAMEBAADBAQAAw...
    </data>
  </layer>
</map>

This is a bug in latest release.这是最新版本中的一个错误。 It's fixed in master branch.它已在 master 分支中修复。 see https://github.com/libgdx/libgdx/pull/5722https://github.com/libgdx/libgdx/pull/5722

You can temporarily use libgdx 1.9.11-SNAPSHOT to have it working.您可以暂时使用 libgdx 1.9.11-SNAPSHOT 使其工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM