cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
/Users/rquesada/progs/cocos2d-iphone/cocos2d/CCTMXXMLParser.h
00001 /*
00002  * cocos2d for iPhone: http://www.cocos2d-iphone.org
00003  *
00004  * Copyright (c) 2009-2010 Ricardo Quesada
00005  * Copyright (c) 2011 Zynga Inc.
00006  * 
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  * 
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  *
00025  *
00026  * TMX Tiled Map support:
00027  * http://www.mapeditor.org
00028  *
00029  */
00030 
00031 /*
00032  * Internal TMX parser
00033  *
00034  * IMPORTANT: These classed should not be documented using doxygen strings
00035  * since the user should not use them.
00036  *
00037  */
00038  
00039 
00040 #import <Availability.h>
00041 #import <Foundation/Foundation.h>
00042 
00043 enum {
00044         TMXLayerAttribNone = 1 << 0,
00045         TMXLayerAttribBase64 = 1 << 1,
00046         TMXLayerAttribGzip = 1 << 2,
00047         TMXLayerAttribZlib = 1 << 3,
00048 };
00049 
00050 enum {
00051         TMXPropertyNone,
00052         TMXPropertyMap,
00053         TMXPropertyLayer,
00054         TMXPropertyObjectGroup,
00055         TMXPropertyObject,
00056         TMXPropertyTile
00057 };
00058 
00059 /* CCTMXLayerInfo contains the information about the layers like:
00060  - Layer name
00061  - Layer size
00062  - Layer opacity at creation time (it can be modified at runtime)
00063  - Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
00064  
00065  This information is obtained from the TMX file.
00066  */
00067 @interface CCTMXLayerInfo : NSObject
00068 {
00069         NSString                        *name_;
00070         CGSize                          layerSize_;
00071         unsigned int            *tiles_;
00072         BOOL                            visible_;
00073         unsigned char           opacity_;
00074         BOOL                            ownTiles_;
00075         unsigned int            minGID_;
00076         unsigned int            maxGID_;
00077         NSMutableDictionary     *properties_;
00078         CGPoint                         offset_;
00079 }
00080 
00081 @property (nonatomic,readwrite,retain)  NSString *name;
00082 @property (nonatomic,readwrite)                 CGSize layerSize;
00083 @property (nonatomic,readwrite)                 unsigned int *tiles;
00084 @property (nonatomic,readwrite)                 BOOL visible;
00085 @property (nonatomic,readwrite)                 unsigned char opacity;
00086 @property (nonatomic,readwrite)                 BOOL ownTiles;
00087 @property (nonatomic,readwrite)                 unsigned int minGID;
00088 @property (nonatomic,readwrite)                 unsigned int maxGID;
00089 @property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
00090 @property (nonatomic,readwrite)                 CGPoint offset;
00091 @end
00092 
00093 /* CCTMXTilesetInfo contains the information about the tilesets like:
00094  - Tileset name
00095  - Tilset spacing
00096  - Tileset margin
00097  - size of the tiles
00098  - Image used for the tiles
00099  - Image size
00100  
00101  This information is obtained from the TMX file. 
00102  */
00103 @interface CCTMXTilesetInfo : NSObject
00104 {
00105         NSString                *name_;
00106         unsigned int    firstGid_;
00107         CGSize                  tileSize_;
00108         unsigned int    spacing_;
00109         unsigned int    margin_;
00110         
00111         // filename containing the tiles (should be spritesheet / texture atlas)
00112         NSString        *sourceImage_;
00113         
00114         // size in pixels of the image
00115         CGSize          imageSize_;
00116 }
00117 @property (nonatomic,readwrite,retain) NSString *name;
00118 @property (nonatomic,readwrite,assign) unsigned int firstGid;
00119 @property (nonatomic,readwrite,assign) CGSize tileSize;
00120 @property (nonatomic,readwrite,assign) unsigned int spacing;
00121 @property (nonatomic,readwrite,assign) unsigned int margin;
00122 @property (nonatomic,readwrite,retain) NSString *sourceImage;
00123 @property (nonatomic,readwrite,assign) CGSize imageSize;
00124 
00125 -(CGRect) rectForGID:(unsigned int)gid;
00126 @end
00127 
00128 /* CCTMXMapInfo contains the information about the map like:
00129  - Map orientation (hexagonal, isometric or orthogonal)
00130  - Tile size
00131  - Map size
00132  
00133  And it also contains:
00134  - Layers (an array of TMXLayerInfo objects)
00135  - Tilesets (an array of TMXTilesetInfo objects)
00136  - ObjectGroups (an array of TMXObjectGroupInfo objects)
00137  
00138  This information is obtained from the TMX file.
00139  
00140  */
00141 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
00142 #if defined(__IPHONE_4_0)
00143 @interface CCTMXMapInfo : NSObject <NSXMLParserDelegate>
00144 #else
00145 @interface CCTMXMapInfo : NSObject
00146 #endif
00147 
00148 #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
00149 @interface CCTMXMapInfo : NSObject <NSXMLParserDelegate>
00150 #endif
00151 {       
00152         NSMutableString *currentString;
00153     BOOL                                storingCharacters;      
00154         int                                     layerAttribs;
00155         int                                     parentElement;
00156         unsigned int            parentGID_;
00157 
00158         
00159         // tmx filename
00160         NSString *filename_;
00161 
00162         // map orientation
00163         int     orientation_;   
00164         
00165         // map width & height
00166         CGSize  mapSize_;
00167         
00168         // tiles width & height
00169         CGSize  tileSize_;
00170         
00171         // Layers
00172         NSMutableArray *layers_;
00173         
00174         // tilesets
00175         NSMutableArray *tilesets_;
00176                 
00177         // ObjectGroups
00178         NSMutableArray *objectGroups_;
00179         
00180         // properties
00181         NSMutableDictionary *properties_;
00182         
00183         // tile properties
00184         NSMutableDictionary *tileProperties_;
00185 }
00186 
00187 @property (nonatomic,readwrite,assign) int orientation;
00188 @property (nonatomic,readwrite,assign) CGSize mapSize;
00189 @property (nonatomic,readwrite,assign) CGSize tileSize;
00190 @property (nonatomic,readwrite,retain) NSMutableArray *layers;
00191 @property (nonatomic,readwrite,retain) NSMutableArray *tilesets;
00192 @property (nonatomic,readwrite,retain) NSString *filename;
00193 @property (nonatomic,readwrite,retain) NSMutableArray *objectGroups;
00194 @property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
00195 @property (nonatomic,readwrite,retain) NSMutableDictionary *tileProperties;
00196 
00198 +(id) formatWithTMXFile:(NSString*)tmxFile;
00200 -(id) initWithTMXFile:(NSString*)tmxFile;
00201 @end
00202 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone API Reference - Generated using Doxygen 1.7.4