# CCTiledMap Class Reference

Inherits from | CCNode : CCResponder : NSObject
Declared in | CCTiledMap.h

## Overview

CCTiledMap knows how to parse and render a TMX map.

### Features:

- Each tile will be treated as an CCSprite
- The sprites are created on demand. They will be created only when you call “[layer tileAt:]”
- Each tile can be rotated / moved / scaled / tinted / “opacitied”, since each tile is a CCSprite
- Tiles can be added/removed in runtime
- The z-order of the tiles can be modified in runtime
- Each tile has an anchorPoint of (0,0)
- The anchorPoint of the TMXTileMap is (0,0)
- The Tiled layers will be added as a child
- The Tiled layers will be aliased by default
- The tileset image will be loaded using the CCTextureCache
- Each tile will have a unique tag
- Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z
- Each object group will be treated as an NSMutableArray
- Object class which will contain all the properties in a dictionary
- Properties can be assigned to the Map, Layer, Object Group, and Object

### Limitations:

- It only supports one tileset per layer.
- Embedded images are not supported
- It only supports the XML format (the JSON format is not supported)

### Notes:

- Each layer is created using an CCTileMapLayer
- You can obtain the layers at runtime by:
- [map getChildByTag: tag_number];
- [map layerNamed: name_of_the_layer];

### Supported editors

- Tiled http://www.mapeditor.org/

## Tasks

### Accessing the Tile Map Attributes

- `mapSize` property
- `tileSize` property
- `mapOrientation` property
- `objectGroups` property
- `properties` property

### Creating a CCTiledMap Object

- `+ tiledMapWithFile:`
- `+ tiledMapWithXML:resourcePath:`

### Initializing a CCTiledMap Object

- `– initWithFile:`
- `– initWithXML:resourcePath:`

### Tiled Map Helpers

- `– layerNamed:`
- `– objectGroupNamed:`
- `– propertyNamed:`
- `– propertiesForGID:`

## Properties

### mapOrientation

Map Orientation method.

`@property (nonatomic, readonly) CCTiledMapOrientation mapOrientation`

#### Declared In

`CCTiledMap.h`

### mapSize

Map size measured in tiles.

`@property (nonatomic, readonly) CGSize mapSize`

#### Declared In

`CCTiledMap.h`

### objectGroups

Object Groups.

`@property (nonatomic, readwrite, strong) NSMutableArray *objectGroups`

#### Declared In

`CCTiledMap.h`

### properties

Tile Properties.

`@property (nonatomic, readwrite, strong) NSMutableDictionary *properties`

#### Declared In

`CCTiledMap.h`

### tileSize

Map Tile size measured in pixels.

`@property (nonatomic, readonly) CGSize tileSize`

#### Declared In

`CCTiledMap.h`

## Class Methods

### tiledMapWithFile:

Creates a returns a Tile Map object using the specified TMX file.

`+ (id)tiledMapWithFile:(NSString *)tmxFile`

#### Parameters

tmxFile

  TMX file to use.

#### Return Value

The CCTiledMap Object.

#### Declared In

`CCTiledMap.h`

### tiledMapWithXML:resourcePath:

Creates a returns a Tile Map object using the specified TMX XML and path to TMX resources.

`+ (id)tiledMapWithXML:(NSString *)tmxString resourcePath:(NSString *)resourcePath`

#### Parameters

tmxString

  TMX XML to use.

resourcePath

  TMX resource path.

#### Return Value

The CCTiledMap Object.

#### Declared In

`CCTiledMap.h`

## Instance Methods

### initWithFile:

Initializes and returns a Tile Map object using the specified TMX file.

`- (id)initWithFile:(NSString *)tmxFile`

#### Parameters

tmxFile

  TMX file to use.

#### Return Value

An initialized CCTiledMap Object.

#### Declared In

`CCTiledMap.h`

### initWithXML:resourcePath:

Initializes and returns a Tile Map object using the specified TMX XML and path to TMX resources.

`- (id)initWithXML:(NSString *)tmxString resourcePath:(NSString *)resourcePath`

#### Parameters

tmxString

  TMX XML to use.

resourcePath

  TMX resource path.

#### Return Value

The CCTiledMap Object.

#### Declared In

`CCTiledMap.h`

### layerNamed:

Return the Tiled Map Layer specified by the layer name.

`- (CCTiledMapLayer *)layerNamed:(NSString *)layerName`

#### Parameters

layerName

  Name of layer to lookup.

#### Return Value

The CCTiledMapLayer object.

#### Declared In

`CCTiledMap.h`

### objectGroupNamed:

Return the Tiled Map Object Group specified by the object group name.

`- (CCTiledMapObjectGroup *)objectGroupNamed:(NSString *)groupName`

#### Parameters

groupName

  Object group name to lookup.

#### Return Value

The CCTiledMapObjectGroup object.

#### Declared In

`CCTiledMap.h`

### propertiesForGID:

Return the properties dictionary for the specified tile GID.

`- (NSDictionary *)propertiesForGID:(unsigned int)GID`

#### Parameters

GID

  GID to lookup.

#### Return Value

The properties NSDictionary.

#### Declared In

`CCTiledMap.h`

### propertyNamed:

Return the value held by the specified property name.

`- (id)propertyNamed:(NSString *)propertyName`

#### Parameters

propertyName

  Property name to lookup.

#### Return Value

The property value object.

#### Declared In

`CCTiledMap.h`