I would like to create a political map where each country is clickable by tapping but I’m not sure the best way to determine which nation was selected. Imagine Risk where each country can be individually clicked to bring up additional information.
My current approach is to make a sprite for each nation where every image is the size of the screen The images are mostly transparent except for the country, that way when all of the images are displayed the countries are in the correct place relative to one another. To determine if a click occurs on an individual country I look to see if the tapped location is a non transparent pixel and check that the sprite’s name is one of the countries. Additionally the nation needs to glow or something when tapped as an indicator, however my current solution is yet another sprite that is displayed.
This seems like a terrible approach and I was wondering what other solutions might achieve the same results. I’m pretty new to SpriteKit so I’m not entirely sure.
The other idea I had was creating a single texture where each country is a different shade of gray, then when I get the tap location I do a lookup on the color at that location and get the corresponding country. However, I’m not sure how to create a hilight or glowing country effect with that method.