我一直在 pygame 中从事 KidsCanCode 项目(https://www.youtube.com/watch?v=3UxnelT9aCo&list=PLsk-HSGFjnaGQq7ybM8Lgkh5EMxUWPm2i),我已经完成了一切。现在我正在尝试通过加载两种不同的平铺格式来创建关卡,但只会加载一种。即使我尝试只加载'level2.tmx',它也行不通。这是代码:
main.py https://drive.google.com/file/d/1deCK3QED_e8uE4oRRECtizgTFMLvwbKN/view?usp=sharing
settings.py https://drive.google.com/file/d/1LvhnJCobweFT462PPXY42_FdnSF2UGs2/view?usp=sharing
sprites.py https://drive.google.com/file/d/1FD-Uj2SjMVNG29IcK5qaLoU6RBIB5I1s/view?usp=sharing
tilemap.py https://drive.google.com/file/d/1JeYiEo-xJHJ0I16geg7jNERAC5pqEIIH/view?usp=sharing
(顺便说一句,在 main.py(load_data) 中,当它说要加载 tiled1.tmx 时,它应该说是 level2.tmx。)
错误是这样的:
TMX compression type: zstd is not supported.
cannot load
done
它仍然加载level1.tmx,游戏正常进行,但我无法加载level2.tmx,如果我尝试加载它来玩,屏幕不会加载并给出错误:
TMX compression type: zstd is not supported.
Traceback (most recent call last):
File "C:\Users\ruben\Documents\MAX\Python\Pygame\tileyLevel\main.py", line 285, in <module>
g.new()
File "C:\Users\ruben\Documents\MAX\Python\Pygame\tileyLevel\main.py", line 120, in new
self.map = TiledMap(path.join(self.map_folder, 'level2.tmx'))
File "C:\Users\ruben\Documents\MAX\Python\Pygame\tileyLevel\tilemap.py", line 22, in __init__
tm = pytmx.load_pygame(filename, pixelalpha=True)
File "C:\Users\ruben\AppData\Local\Programs\Python\Python38\lib\site-packages\pytmx\util_pygame.py", line 141, in load_pygame
return pytmx.TiledMap(filename, *args, **kwargs)
File "C:\Users\ruben\AppData\Local\Programs\Python\Python38\lib\site-packages\pytmx\pytmx.py", line 360, in __init__
self.parse_xml(ElementTree.parse(self.filename).getroot())
File "C:\Users\ruben\AppData\Local\Programs\Python\Python38\lib\site-packages\pytmx\pytmx.py", line 391, in parse_xml
self.add_layer(TiledTileLayer(self, subnode))
File "C:\Users\ruben\AppData\Local\Programs\Python\Python38\lib\site-packages\pytmx\pytmx.py", line 962, in __init__
self.parse_xml(node)
File "C:\Users\ruben\AppData\Local\Programs\Python\Python38\lib\site-packages\pytmx\pytmx.py", line 1044, in parse_xml
raise Exception
Exception
如果有人可以帮助我,那就太好了。谢谢!