SDL - C - How to check if the mouse pointer is on an image?

Asked

Viewed 90 times

1

Hello, I’m starting a learning about the SDL C graphical interface and I plan to make a menu. In this menu there will be options and when the user hovers over some, it will change color (yellow to green) only I’m having difficulty in this. I have already placed the images of the buttons arranged vertically, I wonder how to check if the mouse is on some to render it again.

1 answer

1

When you catch the mouse movement event you compare the mouse coordinates with those of the menu items:

int end_x;
int end_y;
if(e.type == SDL_MOUSEMOTION)
{
    SDL_GetMouseState(&end_x,&end_y);
}

Good luck in school :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.