New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arcade.read_tiled_map() not reading tiles from tileset #252

Open
MushroomMaula opened this Issue Jun 29, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@MushroomMaula

MushroomMaula commented Jun 29, 2018

Bug Report

arcade.read_tiled_map() is not able to get the tiles if they are stored in a tileset and not in the map file

Expected behavior:

read_tiled_map() should support getting the tiles from a tileset
should be pretty easy to implement, the only problem I see is when I call arcade.read_tiled_map('maps/map.tmx') and the tileset is in the maps dir
the source in the xml will be 'tiles.tsx' and not 'maps/tiles.tsx' which leads to an error when trying to parse the file

@MushroomMaula

This comment has been minimized.

Show comment
Hide comment
@MushroomMaula

MushroomMaula Jun 29, 2018

This is what i came up with

        # FILE: arcade.read_tiled_map()
        # LINE: 83
        # ISSUE: #252 
        # checking if tiles are inside the map file
        # checking if tileset is given
        if not tile_tag_list and tileset_tag.attrib.get("source") is not None:

            path_to_tile_set = tileset_tag.attrib.get("source")

            import os
            directory, file = os.path.split(filename)
            # check if map file in diffrent directory
            if directory:
                # if so we need to add the directory to the tileset source
                path_to_tile_set = os.path.join(directory, path_to_tile_set)
            # if not, path_to_tile_set doesnt need to be changed

            # read and parse tileset
            tile_set_tree = etree.parse(path_to_tile_set)
            tile_set_root = tile_set_tree.getroot()
            # Grab each tile
            tile_tag_list = tile_set_root.findall("tile")

MushroomMaula commented Jun 29, 2018

This is what i came up with

        # FILE: arcade.read_tiled_map()
        # LINE: 83
        # ISSUE: #252 
        # checking if tiles are inside the map file
        # checking if tileset is given
        if not tile_tag_list and tileset_tag.attrib.get("source") is not None:

            path_to_tile_set = tileset_tag.attrib.get("source")

            import os
            directory, file = os.path.split(filename)
            # check if map file in diffrent directory
            if directory:
                # if so we need to add the directory to the tileset source
                path_to_tile_set = os.path.join(directory, path_to_tile_set)
            # if not, path_to_tile_set doesnt need to be changed

            # read and parse tileset
            tile_set_tree = etree.parse(path_to_tile_set)
            tile_set_root = tile_set_tree.getroot()
            # Grab each tile
            tile_tag_list = tile_set_root.findall("tile")
@akapkotel

This comment has been minimized.

Show comment
Hide comment
@akapkotel

akapkotel Jul 27, 2018

How did you make it work? It is not working for me, I’am still receiving an error of passing wrong key to the my_map.global_tile_set - probably I do not paste the path in the proper place. Should I paste these lines after line 83 of read_tiled_map() or somewhere else?

akapkotel commented Jul 27, 2018

How did you make it work? It is not working for me, I’am still receiving an error of passing wrong key to the my_map.global_tile_set - probably I do not paste the path in the proper place. Should I paste these lines after line 83 of read_tiled_map() or somewhere else?

@pvcraven pvcraven assigned pvcraven and unassigned pvcraven Jul 29, 2018

@pvcraven pvcraven added the bug label Jul 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment