How to use the pytmx.tmxloader3.TiledLayer function in PyTMX

To help you get started, we’ve selected a few PyTMX examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitcraft / PyTMX / pytmx / tmxloader3.py View on Github external
def parse_layer(tilesets, node):
        """
        parse a layer element and return a layer object

        tilesets is required since we need to mangle gid's here
        """

        layer = TiledLayer()
        layer.data = []
        layer.flipped_tiles = []
        set_properties(layer, node)

        data = None
        next_gid = None

        data_node = node.getElementsByTagName("data")[0]
        attr = get_attributes(data_node)

        if attr["encoding"] == "base64":
            from base64 import b64decode
            data = b64decode(bytes(data_node.lastChild.nodeValue, 'ascii'))

        elif attr["encoding"] == "csv":
            next_gid = map(int, "".join([line.strip() for line in data_node.lastChild.nodeValue]).split(","))