Last active
December 11, 2015 07:49
-
-
Save LearnCocos2D/4569215 to your computer and use it in GitHub Desktop.
KTTilemap API for the individual aspects of a tilemap (map, layers, tilesets, properties, etc.). All of this is configurable at runtime in KoboldTouch. You can create entire tilemaps with all features from scratch at runtime if you want.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef enum : unsigned char | |
| { | |
| KTTilemapOrientationOrthogonal, | |
| KTTilemapOrientationIsometric, | |
| KTTilemapOrientationHexagonal, | |
| } KTTilemapOrientation; | |
| /** Represents a Tilemap. The tilemap is usually created from a TMX file via the parseTMXFile method. */ | |
| @interface KTTilemap : NSObject <NSXMLParserDelegate, NSCoding> | |
| @property (nonatomic) CGSize mapSize; | |
| @property (nonatomic) CGSize gridSize; | |
| @property (nonatomic) NSMutableDictionary* properties; | |
| @property (nonatomic) NSMutableArray* tilesets; | |
| @property (nonatomic) NSMutableDictionary* tileProperties; | |
| @property (nonatomic) NSMutableArray* layers; | |
| @property (nonatomic) KTTilemapOrientation orientation; | |
| -(void) parseTMXFile:(NSString*)tmxFile; | |
| @end | |
| /** TMX Tileset contains all the tileset info, most importantly the tileset image file. | |
| Also holds a reference to the tileset texture after it has been loaded. */ | |
| @interface KTTilemapTileset : NSObject <NSCoding> | |
| { | |
| @private | |
| __weak CCTexture2D* _texture; | |
| unsigned int _textureRectCount; | |
| CGRect* _textureRects; | |
| } | |
| @property (nonatomic, copy) NSString* name; | |
| @property (nonatomic, copy) NSString* imageFile; | |
| @property (nonatomic) unsigned int firstGid; | |
| @property (nonatomic) unsigned int lastGid; | |
| @property (nonatomic) unsigned int tilesPerRow; | |
| @property (nonatomic) unsigned int tilesPerColumn; | |
| @property (nonatomic) int spacing; | |
| @property (nonatomic) int margin; | |
| @property (nonatomic) CGPoint drawOffset; | |
| @property (nonatomic) CGSize tileSize; | |
| @property (nonatomic, readonly) CCTexture2D* texture; | |
| -(CGRect) textureRectForGid:(unsigned int)gid; | |
| @end | |
| /** TMX Layer data. Can be either a tile or object layer. Depending on which it is not all properties are used. */ | |
| @interface KTTilemapLayer : NSObject <NSCoding> | |
| @property (nonatomic, copy) NSString* name; | |
| @property (nonatomic) NSMutableArray* objects; | |
| @property (nonatomic) NSMutableDictionary* properties; | |
| @property (nonatomic, weak) KTTilemap* tilemap; | |
| @property (nonatomic) KTTilemapLayerTiles* tiles; | |
| @property (nonatomic) CGSize size; | |
| @property (nonatomic) unsigned int tilesCount; | |
| @property (nonatomic) int opacity; | |
| @property (nonatomic) BOOL visible; | |
| @property (nonatomic) BOOL isObjectLayer; | |
| // x/y defaults to 0/0 - none of these values can be changed in Tiled, thus they don't appear here | |
| -(unsigned int) tileAt:(CGPoint)tilePos; | |
| -(unsigned int) tileWithFlagsAt:(CGPoint)tilePos; | |
| @end | |
| /** TMX Tiles of a tile layer. This is just a list of GID integers pointing to a specific tile in the tileset. */ | |
| @interface KTTilemapLayerTiles : NSObject <NSCoding> | |
| @property (nonatomic, weak) KTTilemapTileset* tileset; | |
| @property (nonatomic) uint32_t* gid; | |
| -(id) initWithTiles:(uint32_t*)tiles tilemap:(KTTilemap*)tilemap; | |
| @end | |
| typedef enum : unsigned char | |
| { | |
| KTTilemapObjectPolyTypeRectangle = 0, | |
| KTTilemapObjectPolyTypePolygon, | |
| KTTilemapObjectPolyTypePolyline, | |
| } KTTilemapObjectPolyType; | |
| /** TMX "Object" - either a rectangle, open polygon (polyline) or closed polygon */ | |
| @interface KTTilemapObject : NSObject <NSCoding> | |
| @property (nonatomic, copy) NSString* name; | |
| @property (nonatomic, copy) NSString* type; | |
| @property (nonatomic, readonly) CGPoint* points; | |
| @property (nonatomic, readonly) NSUInteger numberOfPoints; | |
| @property (nonatomic) NSMutableDictionary* properties; | |
| @property (nonatomic) CGPoint position; | |
| @property (nonatomic) CGSize size; | |
| @property (nonatomic) int gid; | |
| @property (nonatomic) BOOL visible; | |
| @property (nonatomic) KTTilemapObjectPolyType polyType; | |
| -(void) makePointsFromString:(NSString*)string; | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment