summary refs log tree commit diff stats
path: root/libs/cocos2d/CCTMXXMLParser.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cocos2d/CCTMXXMLParser.h')
-rwxr-xr-xlibs/cocos2d/CCTMXXMLParser.h202
1 files changed, 202 insertions, 0 deletions
diff --git a/libs/cocos2d/CCTMXXMLParser.h b/libs/cocos2d/CCTMXXMLParser.h new file mode 100755 index 0000000..18d7a8a --- /dev/null +++ b/libs/cocos2d/CCTMXXMLParser.h
@@ -0,0 +1,202 @@
1/*
2 * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 *
4 * Copyright (c) 2009-2010 Ricardo Quesada
5 * Copyright (c) 2011 Zynga Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 *
25 *
26 * TMX Tiled Map support:
27 * http://www.mapeditor.org
28 *
29 */
30
31/*
32 * Internal TMX parser
33 *
34 * IMPORTANT: These classed should not be documented using doxygen strings
35 * since the user should not use them.
36 *
37 */
38
39
40#import <Availability.h>
41#import <Foundation/Foundation.h>
42
43enum {
44 TMXLayerAttribNone = 1 << 0,
45 TMXLayerAttribBase64 = 1 << 1,
46 TMXLayerAttribGzip = 1 << 2,
47 TMXLayerAttribZlib = 1 << 3,
48};
49
50enum {
51 TMXPropertyNone,
52 TMXPropertyMap,
53 TMXPropertyLayer,
54 TMXPropertyObjectGroup,
55 TMXPropertyObject,
56 TMXPropertyTile
57};
58
59/* CCTMXLayerInfo contains the information about the layers like:
60 - Layer name
61 - Layer size
62 - Layer opacity at creation time (it can be modified at runtime)
63 - Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
64
65 This information is obtained from the TMX file.
66 */
67@interface CCTMXLayerInfo : NSObject
68{
69 NSString *name_;
70 CGSize layerSize_;
71 unsigned int *tiles_;
72 BOOL visible_;
73 unsigned char opacity_;
74 BOOL ownTiles_;
75 unsigned int minGID_;
76 unsigned int maxGID_;
77 NSMutableDictionary *properties_;
78 CGPoint offset_;
79}
80
81@property (nonatomic,readwrite,retain) NSString *name;
82@property (nonatomic,readwrite) CGSize layerSize;
83@property (nonatomic,readwrite) unsigned int *tiles;
84@property (nonatomic,readwrite) BOOL visible;
85@property (nonatomic,readwrite) unsigned char opacity;
86@property (nonatomic,readwrite) BOOL ownTiles;
87@property (nonatomic,readwrite) unsigned int minGID;
88@property (nonatomic,readwrite) unsigned int maxGID;
89@property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
90@property (nonatomic,readwrite) CGPoint offset;
91@end
92
93/* CCTMXTilesetInfo contains the information about the tilesets like:
94 - Tileset name
95 - Tilset spacing
96 - Tileset margin
97 - size of the tiles
98 - Image used for the tiles
99 - Image size
100
101 This information is obtained from the TMX file.
102 */
103@interface CCTMXTilesetInfo : NSObject
104{
105 NSString *name_;
106 unsigned int firstGid_;
107 CGSize tileSize_;
108 unsigned int spacing_;
109 unsigned int margin_;
110
111 // filename containing the tiles (should be spritesheet / texture atlas)
112 NSString *sourceImage_;
113
114 // size in pixels of the image
115 CGSize imageSize_;
116}
117@property (nonatomic,readwrite,retain) NSString *name;
118@property (nonatomic,readwrite,assign) unsigned int firstGid;
119@property (nonatomic,readwrite,assign) CGSize tileSize;
120@property (nonatomic,readwrite,assign) unsigned int spacing;
121@property (nonatomic,readwrite,assign) unsigned int margin;
122@property (nonatomic,readwrite,retain) NSString *sourceImage;
123@property (nonatomic,readwrite,assign) CGSize imageSize;
124
125-(CGRect) rectForGID:(unsigned int)gid;
126@end
127
128/* CCTMXMapInfo contains the information about the map like:
129 - Map orientation (hexagonal, isometric or orthogonal)
130 - Tile size
131 - Map size
132
133 And it also contains:
134 - Layers (an array of TMXLayerInfo objects)
135 - Tilesets (an array of TMXTilesetInfo objects)
136 - ObjectGroups (an array of TMXObjectGroupInfo objects)
137
138 This information is obtained from the TMX file.
139
140 */
141#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
142#if defined(__IPHONE_4_0)
143@interface CCTMXMapInfo : NSObject <NSXMLParserDelegate>
144#else
145@interface CCTMXMapInfo : NSObject
146#endif
147
148#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
149@interface CCTMXMapInfo : NSObject <NSXMLParserDelegate>
150#endif
151{
152 NSMutableString *currentString;
153 BOOL storingCharacters;
154 int layerAttribs;
155 int parentElement;
156 unsigned int parentGID_;
157
158
159 // tmx filename
160 NSString *filename_;
161
162 // map orientation
163 int orientation_;
164
165 // map width & height
166 CGSize mapSize_;
167
168 // tiles width & height
169 CGSize tileSize_;
170
171 // Layers
172 NSMutableArray *layers_;
173
174 // tilesets
175 NSMutableArray *tilesets_;
176
177 // ObjectGroups
178 NSMutableArray *objectGroups_;
179
180 // properties
181 NSMutableDictionary *properties_;
182
183 // tile properties
184 NSMutableDictionary *tileProperties_;
185}
186
187@property (nonatomic,readwrite,assign) int orientation;
188@property (nonatomic,readwrite,assign) CGSize mapSize;
189@property (nonatomic,readwrite,assign) CGSize tileSize;
190@property (nonatomic,readwrite,retain) NSMutableArray *layers;
191@property (nonatomic,readwrite,retain) NSMutableArray *tilesets;
192@property (nonatomic,readwrite,retain) NSString *filename;
193@property (nonatomic,readwrite,retain) NSMutableArray *objectGroups;
194@property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
195@property (nonatomic,readwrite,retain) NSMutableDictionary *tileProperties;
196
197/** creates a TMX Format with a tmx file */
198+(id) formatWithTMXFile:(NSString*)tmxFile;
199/** initializes a TMX format witha tmx file */
200-(id) initWithTMXFile:(NSString*)tmxFile;
201@end
202