In my game, I have a TMX map that I add a AtlasSpriteManager as a child (the manager for my "hero"). I currently have 2 layers in my map: behind1 and front1. My Hero manager has a Z of 5.
Here's the map's code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
<map version="1.0" orientation="orthogonal" width="192" height="32" tilewidth="10" tileheight="10">
<tileset name="Untitled" firstgid="1" tilewidth="10" tileheight="10">
<image source="map010101.png"/>
</tileset>
<layer name="behind1" width="192" height="32">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAAO3Sy1FCQQBE0SnegyT8kIQgmauQhKBJqJADHcBspmqYhZxTdXe97FIAAAAAAAAAAAAAAID/5m0q5T19pH06TLfbtOxghM/875hO6St9V/7Ya9OygxF+8r/f9JfO6VL5Y69Nyw5GWMylTGlOy7Sab7dp2cEID/nfY3pKz2ld+WOvTcsORnjJ/zZpm17TrvLHXpuWHQAAAAAAAABwv66P0KxxAGAAAA==
</data>
</layer>
<layer name="front1" width="192" height="32">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAAO3SyW0CURRE0S+6cRJMSTBlzpQEUxIYOwcqgN4hPVicI91dLas1AAAAAAAAAAAAAAAAAAAAAIDvsuta26dDOqZT99kNVDrng5d0Tbd0H/hk5QYqPfLB3/RMf+l/4JOVG6g06lvrUp/G6af/7AYqTfLBaZqleVoMfLJyA5WW+eAqrdMmbQc+WbkBAADe9wJ+AfWoAGAAAA==
</data>
</layer>
</map>
As you can see, the first layer listed is behind1. Here's the code I use to reorder the layers:
[map reorderChild:[map layerNamed:@"behind1"] z:4];
This works flawlessly. As soon as I try to do this:
[map reorderChild:[map layerNamed:@"front1"] z:6];
I get this error:
2009-09-16 23:16:03.856 RocketBoy3[4295:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AtlasSpriteManager layerName]: unrecognized selector sent to instance 0x3b6bfe0'
If I modify the code of the map and switch the 2 layer's places, the reorderChild for the 'behind1' layer crashes and the one for 'front1' works fine.
It can only reorder the first layer listed in the .TMX. I don't know if this is a bug or if I'm missing something, but I can't get it to work.
Did anyone experience this?