skt

SKTiledMap

A TMX TileMap framework for SpriteKit. Supporting iOS 8 and OS X 10.10 and above.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

97

Maintenance

Last Commit

1yr ago

Contributors

0

Package

Dependencies

0

License

MIT

Categories

Readme

SKTiledMap

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.

Installation

  • Cocoapods
    1. pod 'SKTiledMap'
    2. Add #import <SKTiledMap/SKTiledMap.h> to your source file.
  • Manually
    1. Download the latest code version
    2. Open your project in Xcode, then drag and drop Framework/ folder into your project
    3. configure Dependencies
    4. Add #import 'SKTiledMap.h' to your source file.

Basic Usage

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.

Features

  • 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

Roadmap

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

Dependencies

  • Ono for parsing XML
  • libz.dylib
  • SpriteKit.framework

DEMO

SKTiledMap-Mac

  • iOS

SKTiledMap

License

SKTiledMap is released under the MIT license. See LICENSE for details.

Example tileset artwork is appropriated to Steffan (TilemapKit)

Image Attributions

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.

Please let me know if you notice any images that may have missing or incorrect attributions, thank you.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100