summary refs log tree commit diff stats
path: root/libs/cocos2d/CCTMXTiledMap.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cocos2d/CCTMXTiledMap.h')
-rwxr-xr-xlibs/cocos2d/CCTMXTiledMap.h145
1 files changed, 145 insertions, 0 deletions
diff --git a/libs/cocos2d/CCTMXTiledMap.h b/libs/cocos2d/CCTMXTiledMap.h new file mode 100755 index 0000000..8f48da3 --- /dev/null +++ b/libs/cocos2d/CCTMXTiledMap.h
@@ -0,0 +1,145 @@
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#import "CCNode.h"
32
33
34@class CCTMXLayer;
35@class CCTMXObjectGroup;
36
37/** Possible oritentations of the TMX map */
38enum
39{
40 /** Orthogonal orientation */
41 CCTMXOrientationOrtho,
42
43 /** Hexagonal orientation */
44 CCTMXOrientationHex,
45
46 /** Isometric orientation */
47 CCTMXOrientationIso,
48};
49
50/** CCTMXTiledMap knows how to parse and render a TMX map.
51
52 It adds support for the TMX tiled map format used by http://www.mapeditor.org
53 It supports isometric, hexagonal and orthogonal tiles.
54 It also supports object groups, objects, and properties.
55
56 Features:
57 - Each tile will be treated as an CCSprite
58 - The sprites are created on demand. They will be created only when you call "[layer tileAt:]"
59 - Each tile can be rotated / moved / scaled / tinted / "opacitied", since each tile is a CCSprite
60 - Tiles can be added/removed in runtime
61 - The z-order of the tiles can be modified in runtime
62 - Each tile has an anchorPoint of (0,0)
63 - The anchorPoint of the TMXTileMap is (0,0)
64 - The TMX layers will be added as a child
65 - The TMX layers will be aliased by default
66 - The tileset image will be loaded using the CCTextureCache
67 - Each tile will have a unique tag
68 - Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z
69 - Each object group will be treated as an NSMutableArray
70 - Object class which will contain all the properties in a dictionary
71 - Properties can be assigned to the Map, Layer, Object Group, and Object
72
73 Limitations:
74 - It only supports one tileset per layer.
75 - Embeded images are not supported
76 - It only supports the XML format (the JSON format is not supported)
77
78 Technical description:
79 Each layer is created using an CCTMXLayer (subclass of CCSpriteBatchNode). If you have 5 layers, then 5 CCTMXLayer will be created,
80 unless the layer visibility is off. In that case, the layer won't be created at all.
81 You can obtain the layers (CCTMXLayer objects) at runtime by:
82 - [map getChildByTag: tag_number]; // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
83 - [map layerNamed: name_of_the_layer];
84
85 Each object group is created using a CCTMXObjectGroup which is a subclass of NSMutableArray.
86 You can obtain the object groups at runtime by:
87 - [map objectGroupNamed: name_of_the_object_group];
88
89 Each object is a CCTMXObject.
90
91 Each property is stored as a key-value pair in an NSMutableDictionary.
92 You can obtain the properties at runtime by:
93
94 [map propertyNamed: name_of_the_property];
95 [layer propertyNamed: name_of_the_property];
96 [objectGroup propertyNamed: name_of_the_property];
97 [object propertyNamed: name_of_the_property];
98
99 @since v0.8.1
100 */
101@interface CCTMXTiledMap : CCNode
102{
103 CGSize mapSize_;
104 CGSize tileSize_;
105 int mapOrientation_;
106 NSMutableArray *objectGroups_;
107 NSMutableDictionary *properties_;
108 NSMutableDictionary *tileProperties_;
109}
110
111/** the map's size property measured in tiles */
112@property (nonatomic,readonly) CGSize mapSize;
113/** the tiles's size property measured in pixels */
114@property (nonatomic,readonly) CGSize tileSize;
115/** map orientation */
116@property (nonatomic,readonly) int mapOrientation;
117/** object groups */
118@property (nonatomic,readwrite,retain) NSMutableArray *objectGroups;
119/** properties */
120@property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
121
122/** creates a TMX Tiled Map with a TMX file.*/
123+(id) tiledMapWithTMXFile:(NSString*)tmxFile;
124
125/** initializes a TMX Tiled Map with a TMX file */
126-(id) initWithTMXFile:(NSString*)tmxFile;
127
128/** return the TMXLayer for the specific layer */
129-(CCTMXLayer*) layerNamed:(NSString *)layerName;
130
131/** return the TMXObjectGroup for the secific group */
132-(CCTMXObjectGroup*) objectGroupNamed:(NSString *)groupName;
133
134/** return the TMXObjectGroup for the secific group
135 @deprecated Use map#objectGroupNamed instead
136 */
137-(CCTMXObjectGroup*) groupNamed:(NSString *)groupName DEPRECATED_ATTRIBUTE;
138
139/** return the value for the specific property name */
140-(id) propertyNamed:(NSString *)propertyName;
141
142/** return properties dictionary for tile GID */
143-(NSDictionary*)propertiesForGID:(unsigned int)GID;
144@end
145