Пример #1
0
def _parse_object_layer(element: etree.Element, ) -> objects.ObjectLayer:
    """Parse the objectgroup element given.

    Args:
        element (etree.Element): Element to be parsed.

    Returns:
        ObjectLayer: The object layer object.
    """
    id_, name, offset, opacity, properties = _parse_layer(element)

    tiled_objects = _parse_objects(element.findall("./object"))

    color = None
    try:
        color = element.attrib["color"]
    except KeyError:
        pass

    draw_order = None
    try:
        draw_order = element.attrib["draworder"]
    except KeyError:
        pass

    return objects.ObjectLayer(
        id_=id_,
        name=name,
        offset=offset,
        opacity=opacity,
        properties=properties,
        tiled_objects=tiled_objects,
        color=color,
        draw_order=draw_order,
    )
Пример #2
0
def _parse_object_layer(element: etree.Element, ) -> objects.ObjectLayer:
    """Parse the objectgroup element given.

    See: https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#objectgroup

    Args:
        element: Element to be parsed.

    Returns:
        ObjectLayer: The object layer object.
    """
    id_, name, offset, opacity, properties = _parse_layer(element)

    color = None
    try:
        color = element.attrib["color"]
    except KeyError:
        pass

    draw_order = None
    try:
        draw_order = element.attrib["draworder"]
    except KeyError:
        pass

    tiled_objects = _parse_tiled_objects(element.findall("./object"))

    return objects.ObjectLayer(
        id_=id_,
        name=name,
        offset=offset,
        opacity=opacity,
        properties=properties,
        color=color,
        draw_order=draw_order,
        tiled_objects=tiled_objects,
    )