Creating a Split Swift Map

I am creating a game in SpriteKit using Swift. A game requires a player to be able to select a specific state in the United States using such a card. enter image description here

Is there a program or technique that I could use to draw the outlines of states and turn each state into its own unique node inside the map? For example, I would like to be able to use the Illinois node, and then my application will find out that I clicked on Illinois. I do not know where to start and understand that this is not an easy task. Any help would be appreciated.

+6
source share
2 answers

The easiest approach I can imagine is to create several images (one for each state) and finally add them to your scene (each in its correct position).

Having a separate sprite for each state will facilitate several operations, such as

  • determining which state was pressed
  • state color binding
  • Increase condition
  • apply texture to state

Image cutting

Starting with the input image that you submitted in your question, you can use an image editing tool (like Pixelmator ) with a mask function to extract images for each state.

Sprite positioning

The same image editor, after you split the images, is likely to provide you with the position of this state inside the canvas. You will need to use them to change the state inside the canvas. Or you can edit the Xcode SpriteKit scene editor to manually position the images.

+2
source

enter image description here Please refer to the link: https://github.com/ArthurGuibert/FSInteractiveMap

Example 3 in a demo is what you are looking for

0
source

All Articles