I'm writing an original (top-down) SimCity clone in Swift and attempting to use SpriteKit as the basis for the game. However, I am running into performance issues when rendering and animating the tile map which represents the city map.
I'm rendering a 44x44 tile map with each tile being 16x16 pixels. Tile animation could happen on any arbitrary tile and is implemented by having a separate image for each frame of the animation. The map is dynamic (naturally) since the player will draw on it and tiles can be animated (roads, etc). I have tried several implementations to render the map the screen and each has had its own performance issues.
What I've tried:
- Each tile is an
SKSpriteNodewith its texture loaded from a texture atlas. Textures were swapped for tiles that were dirty (needed redraw). I disabled physics simulations and physics bodies on the nodes.
- Minimal draws (due to the Texture atlas)
- Code wasn't very complex
- Redrawing the entire map destroyed performance
- Swapping textures to animate was inefficient
- Map was rendered using
- Drawing was relatively efficient
- Dirty rectangle drawing was easy to implement
- Not really suitable for animation (really bad performance)
My question is: What is the most efficient way of rendering/animating my tile map? Is there an optimization I can make to SpriteKit to speed this up? Or do I need to use something lower level (OpenGL/GLSL) to draw/animate the map efficiently?
Any help would be greatly appreciated!