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

Fixed contentScale logic while parsing the tile map file #1362

Merged
merged 2 commits into from
Mar 6, 2016
Merged

Fixed contentScale logic while parsing the tile map file #1362

merged 2 commits into from
Mar 6, 2016

Conversation

xmkevinchen
Copy link
Contributor

No description provided.

@s1ddok
Copy link
Contributor

s1ddok commented Mar 4, 2016

Can you please explain more on why this should be merged and what exactly problems does it solve?

@xmkevinchen
Copy link
Contributor Author

Sure,

Here's the reason I started investigating the TileMaps code, I was trying to load a tile map size (1024 x 1024) on iPad Air 2, and I got the contentSize after parsing from tmx was (256 x 256). But it's supposed to be 512 x 512.

So I started reading the code and the I found

  1. CCTMXXMLParser when reads the tileSize from tmx, the code is doing the calculation based on the contentScale. But in -[CCTMXLayer initWithTilesetInfo:layerInfo:mapInfo] for setting the contentSize, we use the contentScale again to calculate pixelsToPoints which was no sense at this moment. The calculation has been made while parsing the tileSize.
  2. Most of values for the width / height, position (x/y), offset (x/y) are presented in pixels in TMX file, except the mapSize which is kind of for the value of row / column of tiles. So I went through the parsing method to update the calculation.
  3. While debugging, I found for offset, instead of using x/y as keys, Tiled uses offsetx / offsety to present the offset, so I made the change as well

@s1ddok
Copy link
Contributor

s1ddok commented Mar 5, 2016

I can't tell if this a correct PR or no. You could get wrong size because you use 4.0 content scale for iPad. That is why you get 256 result pixels when loading 1024. I need some test cases to reproduce this.

@s1ddok
Copy link
Contributor

s1ddok commented Mar 6, 2016

This PR seems to be fixing the problem with offset that was reported in the forum. Merged.

s1ddok added a commit that referenced this pull request Mar 6, 2016
Fixed contentScale logic while parsing the tile map file
@s1ddok s1ddok merged commit e08ae7b into cocos2d:develop-v3.5 Mar 6, 2016
s1ddok added a commit that referenced this pull request Nov 27, 2016
Fixed contentScale logic while parsing the tile map file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants