Number of nodes are high after loading a TMX file in SpriteKit using JSTileMap

78 views Asked by At

I'm trying to load a 32x22 map with tile size of H:32px W:32px created using Tiled. After following answers here and tutorials on how to load .tmx files using JSTileMap in SpriteKit, I attempted my own:

var worldNode: SKNode!
var tileMap: JSTileMap?
var backgroundLayer: SKNode!

func createWorld(){

    tileMap = JSTileMap(named: "Room1.tmx");
    if tileMap != nil {
        backgroundLayer = SKNode()
        backgroundLayer.addChild(tileMap!)

    }
    worldNode = SKNode()
    worldNode.addChild(backgroundLayer!)

    addChild(worldNode)
}

The map is successfully loaded. My question now is the number of nodes shown on the bottom right is over 700. It seems to be quite high or is it normal to have such number loading tmx based maps?

1

There are 1 answers

0
Whirlwind On

That's fine. You have 704 tiles all together (32x22) , so nodes count is correct. SpriteKit is capable to render hundreds of nodes in a performant way (using batch rendering) and you should not be worried about nodes count as long as number of draw calls, needed for scene rendering, are kept to low. To see this number, you can set SKView's showsDrawCount property to true, like this:

skView.showsDrawCount = true