I'm currently trying to build a little strategy game where players take control of countries on an world. Each player's countries are represented by having a different color background but as each country is a different irregular shape I'm wondering how best to build this. To be clear I know how to change the color of a sprite or texture, but I'm wondering if there's a better approach to building the map then I outline below

My initial thought is that I export each individual country sprite and then use a shader etc. to change the background color when required. To do this I would obviously need to piece together each scene manually and make sure my countries line up correctly against each other to form the whole world.

This means I can't really create any 'dynamic' worlds. i.e. each map has to be hand curated.

Is there a better way to approach this without having uniform shaped countries? Bearing in mind this is a 2D game and there isn't really physics, could I use a physics body or something similar to get the actual shape of a country, and perhaps make sure each sprite has a white/transparent background then just change that particular color? Leaving the border black or whatever color I choose.

My fallback option is just having a building on each country that has a flag representing the faction color as this would be a lot easier to do.


There are a few methods one could use to create procedural irregular shapes that are individually capable of being colored. The simplest of these is likely to use SKShapeNode to create a Node based on a CoreGraphics path. You could use other means of creating procedural irregular shapes, but this is the most straight-forward when working with SpriteKit.

A less procedural but even more straight-forward solution, you could layer multiple sprites on top of one another. If you wanted shapes that were seemingly random but that gives you more control over the process, you can create small parcels of irregular shapes, assigning them to SKSpriteNodes and combining them to form a larger shape.

The number, types, rotations, and placements of these shapes could all be randomized to give significant diversity, and then they can be grouped together as children under the same (Empty) node. This node could then be given a color, applied to all the parcels, and would seem to the user as a single, indivisible, random shape of color.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.