Skip to content

Commit

Permalink
Bug fix for Tmx grouplayer (pythonarcade#648)
Browse files Browse the repository at this point in the history
* Allow getting tmx layer by path

* add tests and demo

* Bug fix.  Added test for edge case also
  • Loading branch information
kfields committed Apr 18, 2020
1 parent a6a6146 commit 34f912b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arcade/tilemap.py
Expand Up @@ -82,7 +82,8 @@ def _get_tilemap_layer(path, layers):
for layer in layers:
if layer.name == layer_name:
if isinstance(layer, pytiled_parser.objects.LayerGroup):
return _get_tilemap_layer(path, layer.layers)
if len(path) != 0:
return _get_tilemap_layer(path, layer.layers)
else:
return layer
return None
Expand Down
7 changes: 7 additions & 0 deletions tests/unit2/test_tilemap_objects.py
Expand Up @@ -55,6 +55,13 @@ def test_one():
#
assert sprite_2.alpha == int(255*.5)

#
# Test edge case with only group name. Should return empty sprite list
#
tile_list_3 = arcade.tilemap.process_layer(tmx_map, "Group", base_directory="test_data")
assert tile_list_3 is not None
assert len(tile_list_3) == 0

#
# Future tests?
#
Expand Down

0 comments on commit 34f912b

Please sign in to comment.