Hi I figured it out. Tiled Maps adds the ‘…’ in the path which means previous folder in the directory hierarchy. Knowing this I was able to place the files in the correct directory.
Summary
Hello,
I have an issue when trying to load a tmx map file into my pygame project.
The issue appears to be with the paths defined in the tsx and the tmx file.
When running this code for example:
import pyglet
import pygame
from pytmx import load_pygame
import pytmx
pygame.init()
screen = pygame.display.set_mode((600, 500))
bg = pytmx.load_pygame("First map.tmx")
while (True):
for event in pygame.event.get():
if (event.type == pygame.QUIT):
quit()
for layer in bg.visible_layers:
for x, y, gid, in layer:
tile = bg.get_tile_image_by_gid(gid)
pygame.display.update()
I get the following Error:
File “C:\Users\project_path\Typing Program\UtilityClasses.py”, line 28, in GetDataFromMap
bg = pytmx.load_pygame(“First map.tmx”)
…
FileNotFoundError: No file ‘…/Tile Sets…/tmw_desert_spacing.png’ found in working directory ‘C:\Users\project_path\Typing Program’.
I have the png image tmw_desert_spacing.png placed at the path Typing Program/Tile Sets/tmw_desert_spacing.png as well directly inside the Typing Program root folder just to be safe. The tsx file is inside the Tile Set folder. The tmx file is inside the project root folder Typing Program.
Since everything seems to be in place, why is it not working? Also why are there the dots in the path between folders? Why is TiledMap adding those? (…/Tile Sets…/tmw_desert_spacing.png)
What do I need to do to fix the issue and how do I need to place the files?
Any help is greatly appreciated!