Sprite Kit render performance using 16x16 tiles vs 32x32 tiles?

565 views Asked by At

I've made a Tiled game. Right now I'm stress testing my phone's capabilities by increasing amount of nodes in the scene. There's physics based stuff, AI movement, Day & Night system, particles popping out here & there & plenty of other stuff going on under the hood for my scenes. What I want to know is there a performance difference in using 16x16 tiles, what I have now, versus using 32x32 tiles? These tiles are basically just an image that was added to the scene; they don't have any physics bodies or anything else of that sort. They do have properties I set upon them when making the map in Tiled, but I don't think that has any performance impact. Each map has several layers (background, vegetation, spawn points, buildings, sometimes a few more). Here is a code snippet of how tiles are rendered for 1 such layer:

        if([map propertiesForGid:tileGid][@"shrub"])
        {
            SKSpriteNode *tile = [layer tileAtCoord:coord];
            tile.name = @"vegShrub";
            [self addChild:tile];
        }
        else if([map propertiesForGid:tileGid][@"tree"])
        {
            SKNode *tile = [[Breakable alloc] initWithWhole:[atlas textureNamed:@"tree"] broken:[atlas textureNamed:@"tree-stump"]];
            tile.position = [self pointForCoord:coord];
            [self addChild:tile];
            [layer removeTileAtCoord:coord];
        }

If I use 32x32 tiles over my current 16x16 tiles, will I somehow free up some memory or "relieve the load" off the system?

1

There are 1 answers

12
sangony On BEST ANSWER

With tile maps, each tile is usually represented by a SKSpriteNode. So if your map is 320 x 320 and you're using 32x32 tiles, you will end up with 100 nodes. Using 16x16 tiles on the same map size will result in 400 nodes. The more nodes, the greater the load.

On another note, you should look into getting the SKAToolKit to parse tile maps in your app. It's open source, free and has a ton of built in features such as auto follow, mini map, etc...