slycrel/JSTileMap

iosmetric map with multiple tilesets

Opened this issue · 6 comments

I have created a isometric map using Tiled. I used 2 tilesets, one contains 64x64 sized tiles and the other contains 64x128 sized tiles. I used 64x64 tiles in Layer 1 and 64x128 tiles in Layer 2. everything looked fine on Tiled, but when I render the map with JSTileMap, all 64x64 sized tiles came out in the correct position, but all 64x128 sized tiles came out in the wrong position. something almost looked like row -1, column -1(in terms of positioning the tiles).
has anyone ran into this problem before?
any help would be greatly appreciated.

I've not done any heavy testing with isometric maps, it doesn't surprise me there may be bugs. If you can attach an example I'd be happy to look at it (realistically later this week or early next week).

Thank you for the prompt response.I've attached an example test01.tmx map and 2 tileset files for your reference.There are 2 layers, first layer were created by using the tiles from 64x64 sized tileset. The trees in 2nd layer were created from 64x128 tileset.(rocks were from 64x64 tileset)If you open test01.tmx in Tiled, you can see everything aligned perfectly. however if you render the map in game using JSTileMap, the trees would come out misaligned.
Please let me know how to fix this. Thank you in advance.

Date: Mon, 14 Dec 2015 12:54:47 -0800
From: notifications@github.com
To: JSTileMap@noreply.github.com
CC: devilling99@hotmail.com
Subject: Re: [JSTileMap] iosmetric map with multiple tilesets (#39)

I've not done any heavy testing with isometric maps, it doesn't surprise me there may be bugs. If you can attach an example I'd be happy to look at it (realistically later this week or early next week).


Reply to this email directly or view it on GitHub.

Hi Bob997, I never did receive the example files you mentioned here. Replying and attaching may not work through github. you can send them directly to me by posting a dropbox link or somesuch, or email me directly, my username @yahoo.com.

Hi Slycrel,

I've have forwarded the samples to your yahoo mailbox a couple of weeks ago. Not sure if you have received them. Please let me know if you didn't and I will forward them again.

Thanks.

Hi Bob997,

Sorry for the delay, I missed those somewhere. I looked at your test map a little today and have some progress for you, but not a complete fix. I still have some zOrdering issues, I'm unsure why the zOrdering isn't working as expected. But the positioning wasn't too bad to fix. Try modifying the if statement in JSTileMap.m at line 198 with the following code:

                // make sure it's in the right position.
                if (mapInfo.orientation == OrientationStyle_Isometric)
                {
                    // if the tile isn't the same size as the standard map tiles, we need to adjust the positioning to be in the center of the sprite.
                    CGFloat widthOffset = 0;
                    CGFloat heightOffset = 0;
                    if (tilesetInfo.tileSize.width > layer.mapTileSize.width)
                        widthOffset = (tilesetInfo.tileSize.width - layer.mapTileSize.width) / 2.0;
                    else
                        widthOffset =   (layer.mapTileSize.width - tilesetInfo.tileSize.width) / 2.0;
                    if (tilesetInfo.tileSize.height > layer.mapTileSize.height)
                        heightOffset = (tilesetInfo.tileSize.height - layer.mapTileSize.height) / 2.0;
                    else
                        heightOffset = (layer.mapTileSize.height - tilesetInfo.tileSize.height) / 2.0;

                    sprite.position = CGPointMake((layer.mapTileSize.width / 2.0) * (layerInfo.layerGridSize.width + col - row - 1) + widthOffset,
                                                  (layer.mapTileSize.height / 2.0) * ((layerInfo.layerGridSize.height * 2 - col - row) - 2) + heightOffset);
                }
                else
                {
                    sprite.position = CGPointMake(col * layer.mapTileSize.width + tilesetInfo.tileSize.width/2.0,
                                                                                (mapInfo.mapSize.height * (layer.mapTileSize.height)) - ((row + 1) * layer.mapTileSize.height) + tilesetInfo.tileSize.height/2.0);
                }

If I get some more time soon I'll have a deeper look at the zOrdering code. And I'll add this test map to the project to be used as an ongoing test. Thanks.

Hi Slycrel,

Thank you for looking into this issue. I will try to modify the code as suggested. Please let me know when you have fixed the zOrdering.

Thanks again.