我正在尝试使用此tmx库https://github.com/renfredxh/tmx/blob/master/tmx.py打开tmx映射。
我的python代码如下所示:
import tmx3
import random
import math
import pygame
from socket import *
from pygame.locals import *
from random import randint
pygame.init()
screen = pygame.display.set_mode((1024,640))
tilemap = tmx3.load('map.tmx', screen.get_size()) 我尝试加载的map.tmx包含两个层。一个没有平铺集的平铺层和一个带有矩形的对象层。
当我尝试运行我的代码时,我得到以下错误:
Traceback (most recent call last):
File "C:\Users\Samy\workspace\Traveler\src\implement.py", line 12, in <module>
tilemap = tmx3.load('map.tmx', screen.get_size())
File "C:\Users\Samy\workspace\Traveler\src\tmx3.py", line 848, in load
return TileMap.load(filename, viewport)
File "C:\Users\Samy\workspace\Traveler\src\tmx3.py", line 727, in load
layer = Layer.fromxml(tag, tilemap)
File "C:\Users\Samy\workspace\Traveler\src\tmx3.py", line 261, in fromxml
data = decompress(b64decode(data))
zlib.error: Error -5 while decompressing data: incomplete or truncated stream我打印了数据,结果是b'‘。有没有人知道这里出了什么问题?
我在这里发现了同样的问题,但没有得到回答:Error using tmx with pygame
发布于 2014-07-22 14:56:15
当我使用纯xml格式的.tmx文件时,我得到了同样的错误。Tiled支持一些不同格式的层数据。(Base64-解压缩,base64-zlib,base64-gzip,csv和xml)看起来这个库需要base64-zlib格式。
https://stackoverflow.com/questions/24870366
复制相似问题