SKTiledMap是用于SpriteKit的TMXTileMap框架。支持iOS8和OSX10.10及以上版本。
这是一个用于解析TiledMapEditor产生的地图的库。
安装Cocoapods
pod'SKTiledMap'
Add#import<SKTiledMap/SKTiledMap.h>toyoursourcefile.
Manually
Downloadthelatestcodeversion
OpenyourprojectinXcode,thendraganddropFramework/folder intoyourproject
configureDependencies
Add#import'SKTiledMap.h'toyoursourcefile.
基本用法SKTMMapLayer *mapLayer = [[SKTMMapLayer alloc] initWithContentsOfFile:@"map.tmx"];[self addChild:mapLayer];// get tile layerSKTMTileLayer *tileLayer = [mapLayer tileLayerWithName:@"Ground"];// get object layerSKTMObjectGroupLayer *objLayer = [mapLayer objectLayerWithName:@"Obj"];// get shape in object layerSKTMObjectGroupShape *heroObjShape = [objLayer shapeWithName:@"Hero"];// get custom properties[heroObjShape.model propertyForName:@"status"];// get image layerSKTMImageLayer *imgLayer = [mapLayer imageLayerWithName:@"Background"];// Coordinates System ConvertCGPoint 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.特点:所有地图类型:正交的等轴测图等轴测(交错)六角形(交错)所有TileLayerFormat:XML格式Base64(未压缩)Base64(gzip压缩)Base64(zlib压缩)CSV所有平铺渲染方式:交错轴(X,Y)交错索引(奇数,偶数)平铺渲染顺序(RightDown,RightUp,LeftDown,LeftUp)翻转/旋转的瓷砖或物体所有对象组形状长方形椭圆多边形折线动画图块支持路线图请查看TMXmapformatreferencepage.
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|-- SKTMMapLayeriOS
评论