The country images overlap each other, and when you click on one country, it’s also within the bounding box that encompasses the neighbouring country. Mouse over doesn’t use the collision box of an image; it uses the bounding box. Hence 2 countries are selected…
As to why 2 are shown - the check whether the variable countrySelected equals object name doesn’t quite work the way you hope. It’s returning back that one of the countries the mouse is over has the right object name. It doesn’t filter the Country list to just that one country. i.e. it just returns true or false; it does not alter the list of candidate country images.
So ,you have 2 immediate solutions -
-
The one @jumpingj suggested (easiest and one I’d recommend too). In a subevent, loop through each selected country and check it’s name matches before showing it :
-
An alternative method is to create a 1x1 pixel sprite, place it where the mouse is clicked, and then check which country is in collision with it.