B4i Library iTiled (for iSpritekit)

Discussion in 'iOS Libraries' started by ilan, Oct 8, 2017.

  1. ilan

    ilan Expert Licensed User


    with iTiled you will be able to import Tiled .tmx files to your B4i (iSpritekit) project.
    it is much more simpler to create games with Tiled.

    you can even create menu scenes or shop scenes and not only the game scene itself.

    what is possible with iTiled:

    - create single/multiple Tile Layers.
    - create single/multiple Tilesets with same or different tile size.
    - create single/multiple Object layers.
    - All 4 Objects types are supported (rect, ellipse, polygon, polyline)
    - polygon and polyline will return a List with all vertices.
    - you can uncheck layers to exclude them from importing
    - very good performance!
    - use custom object properties and import them to your project.

    object list returns a type object:

    Type TileObj(objtype As String, name As Stringid As Int, x As Float, y As Float, width As Float, height As Float, rotation As Float, vertices As List, myproperties As Map)
    using iTiled is very simple.
    you create a Sknode that will hold all tiles on it and will draw everything you created in tiled.
    then you get a list with all objects and create of them you sknodes with physicbodies (like you do in android)

    first, you need to initialize the sknode that will hold all tiled nodes:

    'Initialize Skspritenode
        myTileNode.Position = Functions.CreatePoint(
    then you initiaize iTiled with the sknode:

    'SetUp TileMap (TILED)
    after that if your tmx file contains Objects you can import them by going in a loop through the public object list:

    For i = 0 To iTiled.ObjectList.Size -1

    - .tmx file AND png tileset image need to be in your Files/ Folder (not in Special Folder!)
    - use only CSV tile layer format
    - use only "Based on Tileset image" (and not collection of images)
    - draw only what you have to draw. it is better to draw the backround without Tiled!

    this is a beta version so if you have any issues please report them and i will try to fix everything.
    if you like iTiled then please consider a donation but this is not necessary so iTiled is free to use :)

    if you have a local mac then you need to copy the .a and .h files to your local mac. the .xml file needs to be copied to your windows library folder.

    if you are using a hosted mac you need to copy only the .xml file to your windows library folder and wait until @Erel will upload the .a and .h files to the hosted builder.

    thank you, ilan

    EDIT: 04/02/2018, i have updated iTiled and fixed a lot of bugs. i have also included an example that loads correctly the created objects from your tiled.tmx file. you can easily create physics bodies from those objects by using their vertices (path), width, height, x, y,...

    Attached Files:

    Last edited: Feb 4, 2018
    Erel, JanPRO and Ohanian like this.
  2. ilan

    ilan Expert Licensed User

    btw i am using a Functions code module in my projects thats why you have in the code above:

    myTileNode.Position = Functions.CreatePoint(0,0)
    so just create a code module named "Functions" and copy this code:

    'Code module

    Sub Process_Globals

    End Sub

    Public Sub CreatePoint(X As Float, Y As Float) As Point
    Dim aPoint As Point
    Return aPoint
    End Sub
    Public Sub CreateVector(Dx As Float,Dy As Float) As Vector
    Dim aVector As Vector
    Return aVector
    End Sub

    Public Sub CreateSize(Width As Float, Height As Float) As Size
    Dim aSize As Size
    Return aSize
    End Sub

    Public Sub distance(x1 As Float, x2 As Float, y1 As Float, y2 As Float) As Double
    Dim dX = x2 - x1 As Double
    Dim dY = y2 - y1 As Double      
    Return Sqrt((dX * dX) + (dY * dY)) 'simple distance calculation
    End Sub
  3. ilan

    ilan Expert Licensed User

    hi everyone, for my new b4i app i am using iTiled in a more advanced way and i found lots of bugs. so i fixed a lot of them (i hope all) and i will keep working on it and see if i find more bugs.

    i will update the first post soon and also the example project so i just wanted to let you know if you are using iTiled in a running project that it will be updated soon and you should update it too.

    btw. who is going to use this lib? anyone working on a b4i iSpritekit game?
    i made another library that i want also to share with you guys, its called iAtlas. with iAtlas you can create Atlas sprite-sheets images and get them from that sheet instead of having all images separately in your files folder. (like this it is much more organized!)

    EDIT: post #1 has been updated with the latest iTiled version + example project.
    Last edited: Feb 4, 2018
    JanPRO likes this.
  4. sorex

    sorex Expert Licensed User

    not really but I'm having issues to draw a tiled like map to a canvas (the weird lines thread from 2 days ago).

    so a tutorial or example on how to display a tile based screen/map with spritekit might be handy.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice