def __init__(self, pytmx_layer, pytmx_tiled_map, tile_sprite_handler):
"""
:param pytmx.pytmx.TiledTileLayer pytmx_layer: the underlying pytmx TiledTileLayer
:param pytmx.pytmx.TiledMap pytmx_tiled_map: the underlying pytmx TiledMap object (representing the tmx file)
:param callable tile_sprite_handler: the callable that returns an ndarray, populated with TileSprite objects for storage in this layer
"""
super().__init__(pytmx_layer, pytmx_tiled_map)
self.type_str = self.properties.get("type", "none")
self.type = 0
# get type mask of this layer from `type` property
for t in self.type_str.split(","):
self.type |= Sprite.get_type(t)
# an ndarray holding all single tiles (by x/y position) from this layer
# non-existing tiles are not(!) stored in this ndarray and return None at the respective x/y position
self.tile_sprites = tile_sprite_handler(self)
# update do_render indicator depending on some debug settings
self.do_render = (self.properties["do_render"] == "true" and not (DEBUG_FLAGS & DEBUG_DONT_RENDER_TILED_TILE_LAYERS)) or \
(self.type != Sprite.get_type("none") and (DEBUG_FLAGS & DEBUG_RENDER_COLLISION_TILES))
self.render_order = int(self.properties["render_order"])
# put this layer in one single Sprite that we can then blit on the display (with 'area=[some rect]' to avoid drawing the entire layer each time)
self.pygame_sprite = None
# we are rendering this layer, need to store entire image in this structure
if self.do_render:
self.pygame_sprite = self.build_sprite_surface()
评论列表
文章目录