"""Create a new area from a tmx map This body (called parent) must already be connected to the data tree, otherwise body loading will not work and area building will fail. """ # for platformer maps def toWorld(data, (x, y, z)): """ translate tiled map coordinates to world coordinates """ return z, x*data.tileheight, (y-2)*data.tilewidth area = Area() parent.add(area) area.setParent(parent) area.mappath = res.mapPath(mapname) data = tmxloader.load_tmx(area.mappath) for gid, prop in data.tile_properties.items(): try: prop['guid'] = int(prop['guid']) except KeyError: pass # set the boundries (extent) of this map area.setExtent(((0,0), (data.width * data.tilewidth, data.height * data.tileheight))) props = data.getTilePropertiesByLayer(-1)