Forum > C++ > TMX Maps & Retina Display

TMX Maps & Retina Display

By gmeister26 Posted 2011-07-25 14:53 Comments 5
gmeister26
  • Posts: 13

Hi all

I’m having some issues trying to get TMX Maps to show in Retina Display mode. My general sprites work fine in both modes and the TMX Map works for standard size, however when the hd map is loaded everything appears twice as big on the retina display, instead of being the same equivalant size. Has anyone else tried this or am I missing something? Cheers!
Pseude code:
pDirector
>enableRetinaDisplay(true);
tmx = CCTMXTiledMap::tiledMapWithTMXFile(“alpha.tmx”);
tmxBg = tmx~~>layerNamed;
this~~>addChild(tmx, –1);

Resources:
alpha.tmx (16x16 tiles)
alpha.png (16x16)
alpha-hd.tmx (32x32 tiles)
alpha-hd.png (32x32)

GMTDev
  • Posts: 205
  • Location: Vancouver, Canada

#1 RE: 2011-07-26 19:09

Found the same question here, see if it helps:

http://www.cocos2d-iphone.org/forum/topic/13900

Check out http://www.arrowmania.com - Arrow Mania 2! For iOS, Android and Amazon Kindle Fire. Developed using Cocsos2D-X ;)

gmeister26
  • Posts: 13

#2 RE: 2011-07-27 03:43

Cheers, but I don’t think this is the same issue. I literally just let cocos2d-x load the map and display it, but it doesn’t display correctly on the retina display, it is twice as big as it should be. Has anyone else managed to load and scale a map correctly on the retina display?

GMTDev
  • Posts: 205
  • Location: Vancouver, Canada

#3 RE: 2011-08-04 18:31

Just been trying to do Retina TMX tiled maps myself, can’t get it working in Cocos2d-x (v 1.0.0-x-0.9.0).

I’ve posted screen shots of the normal mode map being displayed (this is what the Retina one should look like too a tree and a bix X in front of the Cocos logo), the Retina mode map, and another Retina mode with a modified TMX file.

Editing my HD “map1-hd.tmx” file and changing all tilesizes to their low res value 32 (they should be 64 for my 64x64 tiles) I get a “better” looking result (see TMX_Retina_with_Tilesizes_32.jpg). Of course changing these values is actually wrong and stops it loading into Tiled editor.

Have also attached the progect source file, it is the Helloworld sample. You will see there is a “map1.tmx”, “map1.png”, “map1-hd.tmx”, “map1-hd.png” in the resources. And the only lines of code added are in “bool HelloWorld::init()” which are:

@
// Set retina display mode
CCDirector::sharedDirector()->enableRetinaDisplay(true);
@

(comment out that line to test low res mode on an iPhone 4) and…

@
// Load in the TMX tile map
CCTMXTiledMap* Map;
//Map = CCTMXTiledMap::tiledMapWithTMXFile(“map1.tmx”);
Map = CCTMXTiledMap::tiledMapWithTMXFile(“map1.tmx”);
addChild(Map, 0, 1 /*kTagTileMap*/);
@

Soooo.. am I doing something wrong or is this a bug?

TMX_Low_Res.jpg - normal res screenshot (75.6 kB)

TMX_Retina.jpg - Retina res screenshot (46.6 kB)

TMX_Retina_with_Tilesizes_32.jpg - Retina res screenshot with edited TMX file to 32 (58.5 kB)

HelloWorld.zip - Helloworld with TMX Retina and Normal Maps Source (1.2 MB)

Check out http://www.arrowmania.com - Arrow Mania 2! For iOS, Android and Amazon Kindle Fire. Developed using Cocsos2D-X ;)

GMTDev
  • Posts: 205
  • Location: Vancouver, Canada

#4 RE: 2011-08-05 12:47

OK, found the problem and have a fix, see http://www.cocos2d-x.org/boards/7/topics/2859

Check out http://www.arrowmania.com - Arrow Mania 2! For iOS, Android and Amazon Kindle Fire. Developed using Cocsos2D-X ;)

edisundong
  • Posts: 4

#5 RE: 2012-05-15 00:18

how can i fix this bug?it’s still is a big bug

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps