TMX Tiled Map Fix for Retina mode iPhone (CCTMXLayer)

TMX Tiled Map Fix for Retina mode iPhone (CCTMXLayer)
0.0 0



Found a bug with CCTMXLayer when using Retina mode in “cocos2d-1.0.0-x-0.9.0”. Have fixed it - see my modified CCTMXLayer.cpp and CCTMXLayer.h attached, just search for “Gav T”.

Fixes are a few lines to account for a “ContentScaleFactor” of 2 in Retina including:-
“m_tMapTileSize” came out double what it should be in the function “CCTMXLayer::initWithTilesetInfo(…)”, also…
“rectForGID” came back with a rect twice the size in function “CCTMXLayer::appendTileForGID(…)”.

Gav T. (1002.4 KB) (5.3 KB) (3.2 KB)


Thanks a lot! Bug #661 created.


Oh just found there is a problem with using tileAt and multi layered maps still - will post an update soon.


This version is fixed and tested a bit more. Works with Retina mode TMX Tiled maps including multi layered and calls to functions which add and remove tiles like tileAt(…).


i recently notices the same problem
thanks for this fix
i am working with the objective-c version of cocos2d and tried porting your fix but it did not work, i guess i did something wrong
do i need to have a -hd version of the tmx file or something?
hope to see this fix in a cocos2d release


Gav T
Thank you for your work.
Could you post a pull request by git?


`Minggo - OK, I’ve not used git but will give it a go (will follow this but for the cocos2d-x version

`rakka - I’ll take a look at the Cocos2D version and get back to you. In answer to your hd question yeah you need the -hd and the normal files (2 TMX files and 2 PNG files).


Gav T
Take it easy. It is not difficult to use git. I think you will lke it after you using it.


it’s fixed or not?please reply me


do you use the latest version?


The Retina TMX problem seems to be back in the latest versions of Cocos2d-x. I’m using version “cocos2d-1.0.1-x-0.11.0 @ Jan 13, 2012” and it works fine. “cocos2d-1.0.1-x-0.12.0 @ Mar 05, 2012” and on no longer work.