How to tap on a hitbox

Hello, I am working on a game for smartphones that requires that the player tap on sprites of US states to select them. Each state is obviously not a square and I edited the hitboxes to resemble their actual shape but the “cursor’/touch” command will trigger no matter where in the sprite I tap.

How can I set a touch command to only trigger inside a hitbox?

Thanks!

Make a proxy.
Don’t use directly the cursor.

Create a new little sprite, let’s go with 10x10px.
Attach always this sprite at the position of the cursor.

In condition check if the sprite is in collision with an sprite_state, you should add all your sprite_state in a group. And use this group instead an object in the condition.

With this condition add also the condition for know when the cursor/touch is pressed.
And add also “trigger once”.

Llet me know if this works for you.
Have a good day
:sunny:

Thanks for responding! Will this command also work with touch in a smartphone or just with a mouse pointer? Just want to make sure someone who knows better can confirm that before I move forward!

Hi,
It should, IIRC touch position essentially moves a virtual mouse cursor.