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
Tasks
Accessing the Tile Map Attributes
-
mapSizeproperty -
tileSizeproperty -
mapOrientationproperty -
objectGroupsproperty -
propertiesproperty
Creating a CCTiledMap Object
Initializing a CCTiledMap Object
Tiled Map Helpers
Properties
mapOrientation
Map Orientation method.
@property (nonatomic, readonly) CCTiledMapOrientation mapOrientationDeclared In
CCTiledMap.hmapSize
Map size measured in tiles.
@property (nonatomic, readonly) CGSize mapSizeDeclared In
CCTiledMap.hobjectGroups
Object Groups.
@property (nonatomic, readwrite, strong) NSMutableArray *objectGroupsDeclared In
CCTiledMap.hClass Methods
tiledMapWithFile:
Creates a returns a Tile Map object using the specified TMX file.
+ (id)tiledMapWithFile:(NSString *)tmxFileParameters
- tmxFile
TMX file to use.
Return Value
The CCTiledMap Object.
Declared In
CCTiledMap.htiledMapWithXML:resourcePath:
Creates a returns a Tile Map object using the specified TMX XML and path to TMX resources.
+ (id)tiledMapWithXML:(NSString *)tmxString resourcePath:(NSString *)resourcePathParameters
- tmxString
TMX XML to use.
- resourcePath
TMX resource path.
Return Value
The CCTiledMap Object.
Declared In
CCTiledMap.hInstance Methods
initWithFile:
Initializes and returns a Tile Map object using the specified TMX file.
- (id)initWithFile:(NSString *)tmxFileParameters
- tmxFile
TMX file to use.
Return Value
An initialized CCTiledMap Object.
Declared In
CCTiledMap.hinitWithXML:resourcePath:
Initializes and returns a Tile Map object using the specified TMX XML and path to TMX resources.
- (id)initWithXML:(NSString *)tmxString resourcePath:(NSString *)resourcePathParameters
- tmxString
TMX XML to use.
- resourcePath
TMX resource path.
Return Value
The CCTiledMap Object.
Declared In
CCTiledMap.hlayerNamed:
Return the Tiled Map Layer specified by the layer name.
- (CCTiledMapLayer *)layerNamed:(NSString *)layerNameParameters
- layerName
Name of layer to lookup.
Return Value
The CCTiledMapLayer object.
Declared In
CCTiledMap.hobjectGroupNamed:
Return the Tiled Map Object Group specified by the object group name.
- (CCTiledMapObjectGroup *)objectGroupNamed:(NSString *)groupNameParameters
- groupName
Object group name to lookup.
Return Value
The CCTiledMapObjectGroup object.
Declared In
CCTiledMap.hpropertiesForGID:
Return the properties dictionary for the specified tile GID.
- (NSDictionary *)propertiesForGID:(unsigned int)GIDParameters
- GID
GID to lookup.
Return Value
The properties NSDictionary.
Declared In
CCTiledMap.h