slycrel / JSTileMap

TMX Map viewer for SpriteKit
Other
212 stars 34 forks source link

With multiple tile layers, only top-most layer showing #6

Closed charlie-s closed 10 years ago

charlie-s commented 10 years ago

I've got multiple tile layers that I've built using Tiled app. When I load the map into a new SKView in Xcode via something like:

self.tileMap = [JSTileMap mapNamed:"1.tmx"];
[self addChild:self.tileMap];

I can see any background layer and the topmost tile layer. Other layers in between do not show. Is this expected?

slycrel commented 10 years ago

Hi @csdco, sorry I missed your question somewhere. Do you have an example map that shows this? I'll see what I can do to reproduce this this evening.

slycrel commented 10 years ago

@csdco I have been unable to reproduce layering as an issue. Can you get me an example of what you are seeing?

charlie-s commented 10 years ago

Hey Slycrel,

Sure thing. Sorry for the delayed response, was tight up on some other work. Here are the 3 pngs used, and I've gist'd the TMX at: https://gist.github.com/csdco/8c1a2a094d4764f78d6b

_block _portal

bg

slycrel commented 10 years ago

I'll see what I can do to take a look tonight and let you know what I find. Thanks for the example!

slycrel commented 10 years ago

@csdco I think I've found the problem. Apparently you have a tileset with two images embedded in it. The first image is seen, the second is apparently not seen. I split out the tilesets and everything works as expected. This may be an issue with the parser -- if the TMX format supports two images within a single tile set (which it seems to handle okay in Tiled, so probably this is the case) then I'll have to fix the parser to honor that. For now you can change your TMX code from this

 <tileset firstgid="1" name="test" tilewidth="16" tileheight="16">
  <tile id="0">
   <image width="16" height="16" source="_block.png"/>
  </tile>
  <tile id="1">
   <image width="16" height="16" source="_portal.png"/>
  </tile>
 </tileset>
 <tileset firstgid="3" name="l" tilewidth="1" tileheight="1"/>

To this

  <tileset firstgid="1" name="test" tilewidth="16" tileheight="16">
    <tile id="0">
      <image width="16" height="16" source="_block.png"/>
    </tile>
  </tileset>
  <tileset firstgid="2" name="test2" tilewidth="16" tileheight="16">
    <tile id="0">
      <image width="16" height="16" source="_portal.png"/>
    </tile>
  </tileset>
  <tileset firstgid="3" name="l" tilewidth="1" tileheight="1"/>

And you should see the problem resolved.

charlie-s commented 10 years ago

I see, I should probably setup my tileset differently. Thanks for the help!

slycrel commented 10 years ago

Note that this is still on my list to fix, but at least you have a workaround for now. Good luck!