我在 Tiled Editor 程序中制作了一个 *tmx 地图。然后我尝试将它导入到我的游戏中。当我将变量更改layers
为0
它可以工作时,但屏幕上只有 1 个图块。我想在我的屏幕上打印整个地图。但我收到以下错误。
Traceback (most recent call last):
File "C:\Users\LL\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytmx\pytmx.py", line 512, in get_tile_image
layer = self.layers[layer]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\LL\Desktop\Erik\RPG_project\RPG project\data\main.py", line 143, in <module>
game_initialize()
File "C:\Users\LL\Desktop\Erik\RPG_project\RPG project\data\main.py", line 117, in game_initialize
map_setup()
File "C:\Users\LL\Desktop\Erik\RPG_project\RPG project\data\main.py", line 140, in map_setup
image = tmxdata.get_tile_image(0, 0, 2)
File "C:\Users\LL\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytmx\pytmx.py", line 514, in get_tile_image
raise ValueError
ValueError
我认为这与我的层次有关。我的地图只有 1 层。我的脚本仍然不起作用。我的地图也使用 Base64(压缩)。和 32 像素的大图块。
from pytmx import load_pygame
def map_setup():
global image
# Getting / Importing the map
tmxdata = load_pygame("Tile_files\\mymap2.tmx")
image = tmxdata.get_tile_image(0, 0, 1) # x, y, layer