A TMX TileMap framework for SpriteKit. Supporting iOS 8 and OS X 10.10 and above.
This is a library for parsing the maps generated by Tiled Map Editor.
- Cocoapods
pod 'SKTiledMap'
- Add
#import <SKTiledMap/SKTiledMap.h>
to your source file.
- Manually
- Download the latest code version
- Open your project in Xcode, then drag and drop
Framework/
folder into your project - configure Dependencies
- Add
#import 'SKTiledMap.h'
to your source file.
SKTMMapLayer *mapLayer = [[SKTMMapLayer alloc] initWithContentsOfFile:@"map.tmx"];
[self addChild:mapLayer];
// get tile layer
SKTMTileLayer *tileLayer = [mapLayer tileLayerWithName:@"Ground"];
// get object layer
SKTMObjectGroupLayer *objLayer = [mapLayer objectLayerWithName:@"Obj"];
// get shape in object layer
SKTMObjectGroupShape *heroObjShape = [objLayer shapeWithName:@"Hero"];
// get custom properties
[heroObjShape.model propertyForName:@"status"];
// get image layer
SKTMImageLayer *imgLayer = [mapLayer imageLayerWithName:@"Background"];
// Coordinates System Convert
CGPoint tilePoint = [mapLayer.mapRenderer screenToTileCoords:CGPointMake(320, 600)];
CGPoint mapPoint = [mapLayer.mapRenderer tileToScreenCoords:CGPointMake(1, 1)];
// more detail you can see in demo or source code.
- All map types:
- Orthogonal
- Isometric
- Isometric (staggered)
- Hexagonal (staggered)
- All TileLayerFormat:
- XML
- Base64 (uncompressed)
- Base64 (gzip compressed)
- Base64 (zlib compressed)
- CSV
- All Tile Render Ways:
- Stagger Axis (X, Y)
- Stagger Index (Odd, Even)
- Tile Render Order (RightDown, RightUp, LeftDown, LeftUp)
- Flipped/Rotated Tiles Or Objects
- All ObjectGroup Shape
- Rectangle
- Ellipse
- Polygon
- Polyline
- Animated tile support
See the TMX map format reference page.
SKTiledMap(root)
└── Framework
│
│-- SKTiledMap.h
│
├── Model
│ |-- TMXObject
│ |-- TMXTile
│ |-- TMXTileset
│ |-- TMXTileLayer
│ |-- TMXObjectGroupNode
│ |-- TMXObjectGroup
│ |-- TMXImageLayer
│ |-- TMXMap
│
├── Classes
│ |-- SKMapRenderer
│ |-- OrthogonalRenderer
│ |-- IsometricRenderer
│ |-- StaggeredRenderer
│ |-- HexagonalRenderer
│
└── SpriteKitNode
|-- SKTMNode
|-- SKTMTileNode
|-- SKTMObjectGroupTile
|-- SKTMObjectGroupShape
│
|-- SKTMLayer
|-- SKTMTileLayer
|-- SKTMObjectGroupLayer
|-- SKTMImageLayer
|-- SKTMMapLayer
- Ono for parsing XML
libz.dylib
SpriteKit.framework
- OSX Download
- iOS
SKTiledMap is released under the MIT license. See LICENSE for details.
Example tileset artwork is appropriated to Steffan (TilemapKit)
Some screenshots show the open-source Tiled Map Editor. Some images in TilemapKit and on this website are from OpenGameArt.org.
Here’s a full list of OpenGameArt authors/contributors, licenses and source links for the images used by TilemapKit.
- CC-BY-SA 3.0
- Clint Bellanger (Grassland Tileset, Cave Tileset) with contributors
- Tim Jonsson, Matthew Ostil (Spell of Mastery Tilesets)
- Attribution Notice: Nikita_Sadkov (The Spell of Mastery strategy game)
- surt (Classical Ruin Tiles)
- TRBRY (Race Track Tiles)
- CC-BY 3.0
- Yar (Isometric 64×64 Outside Tileset)
- GameArtForge (Isometric Cubes – Set 01)
- Calciumtrice (Animated Warrior, Dungeon Tileset)
- Attribution Notice: Animated Warrior by Calciumtrice, usable under Creative Commons Attribution 3.0 license.
- Attribution Notice: Dungeon tileset by Calciumtrice, usable under Creative Commons Attribution 3.0 license.
- “Freeware” * TheInquisitor (RPG Maker XP World Map Tile Set)
- Public Domain
- ansimuz (RPG Town Pixel Art Assets)
- pixel32 (Pixel Hex Tilesets Enhanced)
- Kenney (Hexagon Tiles 93x, Isometric City, Platformer Art Complete Pack)
- Hyptosis (Mage City Arcanos)
- Buch (Dungeon Tileset)
- adythewolf (Hex Tileset Pack)
- Guyome41 (Natural Word)
Please let me know if you notice any images that may have missing or incorrect attributions, thank you.