【发布时间】:2014-09-12 06:27:54
【问题描述】:
我正在尝试用这个 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
【问题讨论】: