Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load a .tmx (Tiled Map) in Sprite Kit?

Tags:

ios

sprite-kit

Is there a (preferably easy) way to load a .tmx file in iOS 7's Sprite Kit? If not, are there any alternatives?

like image 364
joeelectricity Avatar asked Aug 23 '13 15:08

joeelectricity


3 Answers

you should use JSTileMap that is designed to work with Sprite Kit

  • add JSTileMap files to your project
  • add libz.dylib to the linked frameworks and libraries section of your project
  • import JSTileMap.h

and load a map with:

JSTileMap *tiledMap = [JSTileMap mapNamed:@"mapFileName.tmx"];
if (tiledMap) [mySKNode addChild:tiledMap];

Here is the source: https://github.com/slycrel/JSTileMap

Good Luck!!

like image 80
Julio Montoya Avatar answered Nov 13 '22 20:11

Julio Montoya


Check out TilemapKit for Sprite Kit. Unlike other solutions it loads and renders all (!) map types and variations supported by Tiled, including staggered iso and hex maps!

TilemapKit is properly engineered like a OOP framework should be, and exposes all data that is stored in the TMX file. In other words it's definitely not just a single class that got everything crammed into it.

Tile picking (point to coord, coord to point conversion) for all map types/variations is built-in. More awesome features on the way, review the roadmap and check out the Class Reference.

TilemapKit is also tested to be fully compatible with Swift and Mac apps, too.

Visit the TilemapKit forum if you have any questions or requests. I'm also posting frequent development reports so you can check what's coming up next.

Disclaimer: If it isn't obvious by now, I'm one of the TilemapKit developers. :)

like image 27
LearnCocos2D Avatar answered Nov 13 '22 20:11

LearnCocos2D


This is the best I have found. I am not sure if the do-it-yourself method would work this instance as I haven't tried implementing it yet.

http://gamedev.tutsplus.com/tutorials/implementation/parsing-tiled-tmx-format-maps-in-your-own-game-engine/

like image 2
Calm Turtle Avatar answered Nov 13 '22 20:11

Calm Turtle