Assuming the following XML file called "example.xml":
<?xml version="1.0"?> <resource> <requires file="ground-tiles.xml" namespace="ground" /> <rectmap id="level1"> <column> <cell tile="ground:grass" /> <cell tile="ground:house"> <property type="bool" name="secretobjective" value="True" /> </cell> </column> </map> </resource>
You may load that resource and examine it:
>>> r = load('example.xml') >>> map = r['level1']
and then, assuming that level1 is a map:
>>> scene = cocos.scene.Scene(map)
and then either manually select the tiles to display:
>>> map.set_view(0, 0, window_width, window_height)
or if you wish for the level to scroll, you use the ScrollingManager:
>>> from cocos import layers >>> manager = layers.ScrollingManager() >>> manager.add(map)
and later set the focus with:
>>> manager.set_focus(focus_x, focus_y)
See the section on controlling map scrolling below for more detail.