Game Development Reference
In-Depth Information
Figure 11-19 . Add a blocks_movement tile property
With the Collisions layer selected, draw on the tilemap with the tile that has the
blocks_movement property set. Place a tile everywhere you don't want the player
to move onto—for example, walls, mountains, houses, and so on.
The tilemap isometric-with-border.tmx in the IsoTilemap03 project is
already prepared with a Collisions layer. The Collisions layer is only for checking
whether a tile can be moved on and should not be displayed in the game, so the first
thing you do in the init method of the TileMapLayer class is to set this layer in-
visible (see Listing 11-9 ) .
Listing 11-9. Hiding the Collisions Layer
CCTMXTiledMap* tileMap = [CCTMXTiledMap tiledMapWithTMXFile:←
@"isometric-with-border.tmx"];
[self addChild:tileMap z:-1 tag:TileMapNode];
CCTMXLayer* collisionsLayer = [tileMap layerNamed:@"Collisions"];
collisionsLayer.visible = NO;
To check whether a certain tile coordinate is blocked, I've added the isTilePosB-
locked method to the IsoTilemap03 project, as shown in Listing 11-10 .
Listing 11-10. Determine Whether a Tile Is Blocked
-(BOOL) isTilePosBlocked:(CGPoint)tilePos tileMap:(CCTMXTiledMap*)tileMap
{
CCTMXLayer* layer = [tileMap layerNamed:@"Collisions"];
 
 
 
 
 
Search Nedrilad ::




Custom Search