KKTilemapTileset Class Reference
Inherits from | NSObject |
Declared in | KKTilemapTileset.h |
Overview
TMX Tileset contains all the tileset data, most importantly the tileset image file and tile properties. Also holds a reference to the tileset texture after it has been loaded. Accessing the texture property will load the texture.
Tasks
-
tilemap
property -
name
property -
imageFile
property -
alternateTileset
property -
firstGid
property -
lastGid
property -
tilesPerRow
property -
tilesPerColumn
property -
spacing
property -
margin
property -
drawOffset
property -
tileSize
property -
texture
property -
tileTextures
property -
properties
property -
tileProperties
property -
– textureForGid:
-
– textureForGidWithoutFlags:
-
– setAlternateTileset:
Properties
alternateTileset
Points to the alternate tileset, used to draw tiles of this tileset from a different texture. Set by calling replaceTileset:withTileset: on KTTilemap.
@property (atomic, readonly) KKTilemapTileset *alternateTileset
Declared In
KKTilemapTileset.h
drawOffset
Drawing offset determines placement of tiles relative to the tile’s origin. Can be used if tileset should not align with the grid but offset by a certain distance from the grid. TILED-EDITABLE
@property (atomic) CGPoint drawOffset
Declared In
KKTilemapTileset.h
firstGid
The first GID in this tileset. It’s the top-left tile in the tileset.
@property (atomic) gid_t firstGid
Declared In
KKTilemapTileset.h
imageFile
The image file without the path. Assumes the image file is in bundle’s root folder.
@property (nonatomic, copy) NSString *imageFile
Declared In
KKTilemapTileset.h
lastGid
The last GID in this tileset. It’s the bottom-most, right-most tile in the tileset. Caution: lastGid is only valid after the tileset texture has been loaded. It will be 0 before that.
@property (atomic) gid_t lastGid
Declared In
KKTilemapTileset.h
margin
The margin defines how much spacing (in points) there is from the texture border to the first tile. Margin is the same for both horizontal and vertical.
@property (atomic) int margin
Declared In
KKTilemapTileset.h
name
The name of the tileset. TILED-EDITABLE
@property (atomic, copy) NSString *name
Declared In
KKTilemapTileset.h
properties
The tileset’s properties. Properties for individual tiles are in tileProperties.
@property (atomic, readonly) KKTilemapProperties *properties
Declared In
KKTilemapTileset.h
spacing
How much space (in points) is between individual tiles. If there’s a spacing of 2, there will be a spacing of 2 points (4 pixels for -hd tileset images) between two adjacent tiles. Spacing is the same for both horizontal and vertical.
@property (atomic) int spacing
Declared In
KKTilemapTileset.h
texture
The texture used by this tileset. If this property is accessed while it’s still nil, it will load the texture.
@property (atomic, readonly) SKTexture *texture
Declared In
KKTilemapTileset.h
tileProperties
Contains each tile’s properties. Properties for the tileset itself are in properties.
@property (atomic, readonly) KKTilemapTileProperties *tileProperties
Declared In
KKTilemapTileset.h
tileSize
The size of tiles (in points).
@property (atomic) CGSize tileSize
Declared In
KKTilemapTileset.h
tileTextures
The textures for each tile in the tileset. The index of a texture for a specific gid is obtained by subtracting firstGid from gid: textureIndes = gid - firstGid
@property (atomic, readonly) NSArray *tileTextures
Declared In
KKTilemapTileset.h
tilemap
Reference to the owning KTTilemap object. Mainly for internal use.
@property (atomic, weak) KKTilemap *tilemap
Declared In
KKTilemapTileset.h
Instance Methods
textureForGid:
Gets the texture of a tile GID from this tileset.
- (SKTexture *)textureForGid:(gid_t)gid
Parameters
- gid
The tile gid whose texture should be returned.
Return Value
The texture for a specific GID, or nil if the gid is not in this tileset.
Declared In
KKTilemapTileset.h
textureForGidWithoutFlags:
Gets the texture of a tile GID from this tileset. Gid must not have any flags set.
- (SKTexture *)textureForGidWithoutFlags:(gid_t)gidWithoutFlags
Parameters
- gid
The tile gid without flags whose texture should be returned.
Return Value
The texture for a specific GID, or nil if the gid is not in this tileset.
Declared In
KKTilemapTileset.h