Search code examples
cocos2d-iphoneretina-display

Cocos2D: Could not add isometric tilemap for retina and non-retina


I am having a trouble. I am using cocos2d with UIKit. Cocos2d version is 1.0.1.

I have added tiled map to project like it is suggested in documentation: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:how_to_develop_retinadisplay_games_in_cocos2d#ccnode_details I have done everything, enabled retina, created hd map as said.

I later position some sprites relative to tile map, and I use tile map coordinate system to position them, so I use it's size and tile size.

On non-retina everything is positioned properly and works fine, but on retina everything is messed up. It looks like tile size of the tiled map is not in points but in pixels, so every calculations which are done are scaled twice, which is bad. I could divide calculations with CC_CONTENT_SCALE_FACTOR but that would require lot of calculating, and, as I understand, that is what cocos2d retina support should do under the hood.

Does somebody have an idea what should I do next, or maybe has some tutorial link where isometric tiled maps are added for both screen dimensions and that works ok?


Solution

  • Cocos2D's tilemap implementation is not fully Retina compatible. As you noticed, some coordinates are in pixels even today in cocos2d 2.0. There's nothing else but to divide by content scale factor.

    This shouldn't be any performance problem. Your bigger performance problem will be cocos2d's ineffective tilemap renderer, ie the larger the tilemap the slower the performance because cocos2d renders all tiles every time.