[SDL] How to use buttons

Patricia Curtis patricia.curtis at gmail.com
Wed Apr 4 21:16:33 PDT 2007


Hi
   Buttons are simple, Make a Global dest SDL_Rect for the button and blit
to the screen with that rect, on your mouse motion event check the mouse pos
is within the Rect, that will give you the mouse over. then on the mouse
down event again check if the mouse is within the Rect and then do what ever
action you require. my personal choice is to do the action on the mouse up
rather than the down.

its a simple collision check
if(MouseX>ButtonRect.x && MouseX<ButtonRect.x+ButtonRect.w && MouseY>
ButtonRect.y && MouseY<ButtonRect.y+ButtonRect.h)
{
//Do somthing
}

Trish x
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070405/d4b2ff15/attachment.html 


More information about the SDL mailing list