Game Development Reference
In-Depth Information
Loading the Isometric Tilemap in Cocos2d
This is easy. Compared to orthogonal tilemaps, you don't need to change anything ex-
cept load the isometric.tmx file instead of orthogonal.tmx .
CCTMXTiledMap* tileMap = [CCTMXTiledMap tiledMapWithTMXFile:@"isometric.tmx"];
[self addChild:tileMap z:-1 tag:TileMapNode];
tileMap.position = CGPointMake(−500, -300);
I do set the isometric tilemap's position to −500, −300 right away, assuming the
tilemap size is 30x30 tiles. This approximately centers the screen on the lower corner
of the small village on the north of the tilemap in Figure 11-11 . I do this to illustrate the
following point about properly setting up Cocos2D for isometric tilemaps, and in Fig-
ure 11-12 you can see there's something obviously wrong with the tilemap.
Figure 11-12 . Without 2D projection, the Ground layer will render incorrectly
Set up Cocos2d for Isometric Tilemaps
If you followed the creation of the tilemap thus far and you set the cc_vertexz
properties on the ground and objects layers in Tiled as described earlier, the resulting
tilemap may look like the one in Figure 11-12 . Somehow, the Ground layer is zoomed
far out, and tiles from the Objects layer seem to be floating in midair. It looks like a
scary place to be.
 
 
Search Nedrilad ::




Custom Search