| Wil Prim (2) | |||
|
So I tried making a simple program that has a button on screen and when the user hovers there mouse over the button it will change color... I put the button location in a SDL_Rect and the blitted it to the screen. Now I try to use an if statement to test whether the mouse is within the button barriers... I ran the program and the button was on screen but when I hovered my mouse over it the button didn't change color. I moved my mouse over to a part of the screen to the left of the button and the button changed colors! I did a test, putting the cords of my mouse in a string and blitting it as a message and when I put my cursor to the part of the screen that changes the color. The location is at where I wanted the button to go; however, the button is about 100 pixels down and 100 to the right of that location. Why is it that SDL is putting the surface not where i want it? CODE:
NOTE: apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL); That is the prototype for apply_surface :) kk ty! | |||
|
|
|||
| Peter87 (3687) | |
|
You are drawing the button in the middle of the screen but when you check if the pointer is inside the button you assume the top left corner of the button is at position (200,200). On line 81 you are using == when it should be =. | |
|
Last edited on
|
|
| Wil Prim (2) | |
| ty! lol | |
|
|
|