Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iosmetric map with multiple tilesets #39

Open
Bob997 opened this issue Dec 14, 2015 · 6 comments
Open

iosmetric map with multiple tilesets #39

Bob997 opened this issue Dec 14, 2015 · 6 comments

Comments

@Bob997
Copy link

Bob997 commented Dec 14, 2015

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.

@slycrel
Copy link
Owner

slycrel commented Dec 14, 2015

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).

@Bob997
Copy link
Author

Bob997 commented Dec 15, 2015

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: [email protected]
To: [email protected]
CC: [email protected]
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.

@slycrel
Copy link
Owner

slycrel commented Dec 26, 2015

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.

@Bob997
Copy link
Author

Bob997 commented Jan 20, 2016

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.

@slycrel
Copy link
Owner

slycrel commented Jan 23, 2016

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.

@Bob997
Copy link
Author

Bob997 commented Jan 26, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants