Say I had a map like the one displayed above. What would be the best method of creating a collision map for each individual state where I can click individually?


Convert your image to grey-scale. Make sure you have no two states that have the same grey. (You have to tweak the image.)

Have an infrastructure that maps the grey colour to a state.

Then when you mouse-over the map, pick the pixel colour that is under the mouse pointer, and search for it in the map.

You'll know what state you want to select this way.

  • \$\begingroup\$ Wonderful solution! \$\endgroup\$ – BruceTheGoose Apr 19 '16 at 1:29
  • \$\begingroup\$ Update: I managed to implement this. Now how would I go about changing the state's color when the mouse is over the state? \$\endgroup\$ – BruceTheGoose Apr 22 '16 at 23:59
  • 1
    \$\begingroup\$ @BruceTheGoose Post a new question :) You can link to this one here if it's relevant. \$\endgroup\$ – Vaillancourt Apr 23 '16 at 0:00

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.