Does Sprite Kit provide performance using 16x16 tiles versus 32x32 tiles?

I made a tile game. Right now I'm under stress testing my phone capabilities by increasing the number of nodes in the scene. There are physics-based things, AI movement, day and night system, particles that appear here as well, and a lot of other things that happen under the hood for my scenes. I want to know if there is a performance difference in using 16x16 tiles that I have now versus using 32x32 tiles? These tiles are just an image that has been added to the scene; they don't have any physical bodies or anything like that. They have properties that I put on them when I created the map in Tiled, but I don't think this has an impact on performance. Each map has several layers (background, vegetation, spawn points, buildings, sometimes several more). Here is a code snippet forhow tiles are displayed for one 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 on top of my 16x16 tiles, will I somehow free some memory or "shed the load" from the system?

+3


source to share


1 answer


With tile maps, each tile is usually represented by an SKSpriteNode. So if your map is 320 x 320 and you use 32x32 tiles, you get 100 nodes. Using 16x16 tiles with the same map size will result in 400 nodes. The more nodes, the greater the load.



On another note, you should look into SKAToolKit to parse tile maps in your application. It's open source, free, and has tons of built-in features like auto-tracking, mini-map, etc.

+4


source







All Articles