#import <CCTMXLayer.h>
Inherits CCSpriteSheet.

Public Member Functions | |
| (id) | - initWithTilesetInfo:layerInfo:mapInfo: |
| (void) | - releaseMap |
| (CCSprite *) | - tileAt: |
| (unsigned int) | - tileGIDAt: |
| (void) | - setTileGID:at: |
| (void) | - removeTileAt: |
| (CGPoint) | - positionAt: |
| (id) | - propertyNamed: |
| (void) | - setupTiles |
| (id) | - addChild:z:tag: |
Static Public Member Functions | |
| (id) | + layerWithTilesetInfo:layerInfo:mapInfo: |
Properties | |
| NSString * | layerName |
| CGSize | layerSize |
| CGSize | mapTileSize |
| unsigned int * | tiles |
| CCTMXTilesetInfo * | tileset |
| int | layerOrientation |
| NSMutableArray * | properties |
CCTMXLayer represents the TMX layer.
It is a subclass of CCSpriteSheet. By default the tiles are rendered using a CCTextureAtlas. If you mofify a tile on runtime, then, that tile will become a CCSprite, otherwise no CCSprite objects are created. The benefits of using CCSprite objects as tiles are:
If the layer contains a property named "cc_vertexz" with an integer (in can be positive or negative), then all the tiles belonging to the layer will use that value as their OpenGL vertex Z for depth.
On the other hand, if the "cc_vertexz" property has the "automatic" value, then the tiles will use an automatic vertex Z value. Also before drawing the tiles, GL_ALPHA_TEST will be enabled, and disabled after drawing them. The used alpha func will be:
glAlphaFunc( GL_GREATER, value )
"value" by default is 0, but you can change it from Tiled by adding the "cc_alpha_func" property to the layer. The value 0 should work for most cases, but if you have tiles that are semi-transparent, then you might want to use a differnt value, like 0.5.
For further information, please see the programming guide:
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps
Definition at line 64 of file CCTMXLayer.h.
| - (id) addChild: | (CCNode *) | node | ||
| z: | (int) | z | ||
| tag: | (int) | tag | ||
CCTMXLayer doesn't support adding a CCSprite manually.
| - (id) initWithTilesetInfo: | (CCTMXTilesetInfo *) | tilesetInfo | ||
| layerInfo: | (CCTMXLayerInfo *) | layerInfo | ||
| mapInfo: | (CCTMXMapInfo *) | mapInfo | ||
initializes a CCTMXLayer with a tileset info, a layer info and a map info
| + (id) layerWithTilesetInfo: | (CCTMXTilesetInfo *) | tilesetInfo | ||
| layerInfo: | (CCTMXLayerInfo *) | layerInfo | ||
| mapInfo: | (CCTMXMapInfo *) | mapInfo | ||
creates a CCTMXLayer with an tileset info, a layer info and a map info
| - (CGPoint) positionAt: | (CGPoint) | tileCoordinate |
returns the position in pixels of a given tile coordinate
| - (id) propertyNamed: | (NSString *) | propertyName |
return the value for the specific property name
| - (void) releaseMap |
dealloc the map that contains the tile position from memory. Unless you want to know at runtime the tiles positions, you can safely call this method. If you are going to call [layer tileGIDAt:] then, don't release the map
| - (void) removeTileAt: | (CGPoint) | tileCoordinate |
removes a tile at given tile coordinate
| - (void) setTileGID: | (unsigned int) | gid | ||
| at: | (CGPoint) | tileCoordinate | ||
sets the tile gid (gid = tile global id) at a given tile coordinate. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. If a tile is already placed at that position, then it will be removed.
| - (void) setupTiles |
Creates the tiles
| - (CCSprite*) tileAt: | (CGPoint) | tileCoordinate |
returns the tile (CCSprite) at a given a tile coordinate. The returned CCSprite will be already added to the CCTMXLayer. Don't add it again. The CCSprite can be treated like any other CCSprite: rotated, scaled, translated, opacity, color, etc. You can remove either by calling:
| - (unsigned int) tileGIDAt: | (CGPoint) | tileCoordinate |
returns the tile gid at a given tile coordinate. if it returns 0, it means that the tile is empty. This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap])
- (NSString*) layerName [read, write, retain] |
name of the layer
Definition at line 91 of file CCTMXLayer.h.
- (int) layerOrientation [read, write, assign] |
Layer orientation, which is the same as the map orientation
Definition at line 101 of file CCTMXLayer.h.
- (CGSize) layerSize [read, write, assign] |
size of the layer in tiles
Definition at line 93 of file CCTMXLayer.h.
- (CGSize) mapTileSize [read, write, assign] |
size of the map's tile (could be differnt from the tile's size)
Definition at line 95 of file CCTMXLayer.h.
- (NSMutableArray*) properties [read, write, retain] |
properties from the layer. They can be added using Tiled
Definition at line 103 of file CCTMXLayer.h.
- (unsigned int*) tiles [read, write, assign] |
pointer to the map of tiles
Definition at line 97 of file CCTMXLayer.h.
- (CCTMXTilesetInfo*) tileset [read, write, retain] |
Tilset information for the layer
Definition at line 99 of file CCTMXLayer.h.