3
\$\begingroup\$

map

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?

\$\endgroup\$
1

1 Answer 1

5
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ Wonderful solution! \$\endgroup\$ Commented Apr 19, 2016 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\$ Commented Apr 22, 2016 at 23:59
  • 1
    \$\begingroup\$ @BruceTheGoose Post a new question :) You can link to this one here if it's relevant. \$\endgroup\$
    – Vaillancourt
    Commented Apr 23, 2016 at 0:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .