On Mon, Dec 8, 2008 at 9:49 AM, s73v3r <[EMAIL PROTECTED]> wrote:
> I'm getting started with Cocos2D, and I'm working on generating a map.
> I can get the map set up in XML, and I was wondering if there was an
> attribute to set a path or border on the map where my character
> sprites would be limited to going. Like, if I were to have a tile for
> grass, and one for dirt, set it up so the characters could only go on
> the dirt, and stay off the grass. If not, what is the preferred method
> for doing this?
You can achieve this by setting a property on the tile (or the map
cell, but it's more consistent to do it on the tile) in the XML file
which says the tile is impassable. For example your XML could have:
<?xml version="1.0"?>
<resource>
<tileset>
<tile id="ground-cobble">
<image ref="i-ground-cobble" /></tile>
<tile id="water">
<property name="impassable" type="bool" value="True" />
<image ref="i-water" /></tile>
</tileset>
</resource>
Then you may:
ground_map = cocos.tiles.load('map_filename.xml')['map_id']
current_cell = (1, 1)
if ground_map.get('impassable'):
# block movement
else:
# allow movement
I've added some more docs to the tiles module to explain this better.
Richard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---