Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.background_color = node.get('backgroundcolor',
self.background_color)
# *** do not change this load order! *** #
# *** gid mapping errors will occur if changed *** #
for subnode in node.findall('layer'):
self.add_layer(TiledTileLayer(self, subnode))
for subnode in node.findall('imagelayer'):
self.add_layer(TiledImageLayer(self, subnode))
for subnode in node.findall('objectgroup'):
self.add_layer(TiledObjectGroup(self, subnode))
for subnode in node.findall('tileset'):
self.add_tileset(TiledTileset(self, subnode))
# "tile objects", objects with a GID, have need to have their attributes
# set after the tileset is loaded, so this step must be performed last
# also, this step is performed for objects to load their tiles.
# tiled stores the origin of GID objects by the lower right corner
# this is different for all other types, so i just adjust it here
# so all types loaded with pytmx are uniform.
# iterate through tile objects and handle the image
for o in [o for o in self.objects if o.gid]:
# gids might also have properties assigned to them
# in that case, assign the gid properties to the object as well
p = self.get_tile_properties_by_gid(o.gid)
if p:
def add_tileset(self, tileset):
""" Add a tileset to the map
:param tileset: TiledTileset
"""
assert (isinstance(tileset, TiledTileset))
self.tilesets.append(tileset)