Help with selection [SOLVED]

Aight, so I’m making a small geography game. i have got to the point where it will choose a country for you to guess but if another countries hit box is touching it also counts that country and will show them both (they are hidden to start).

I want it to only show the right country that is the variables value but the “show” action won’t let me. I assume someone on here will know how to do this better. Maybe you even know abetter method for picking.

Hello @GDTaco ,
Hoping to understand correclty your question.
1- if you use “at begin of scene” trigger once is not necessary
2- in the second block, you compare the touched country name with the text showned on the screen. If they are the same, you want to show the countrie. I suggest you to insert the loop named “for each object” to compare all instances of country with the text and show the correct one.



I don’t know that that would help with showing only the correct country.

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 -

  1. 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 :

  2. 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.

1 Like

Thank you both i sort of used a combo of both suggestions and it works. GDev forums never fail.

1 Like