if (mouse_x < 230 && mouse_x > test.x && mouse_y < 190 && mouse_y > test.x && hover == 0)
{
clear_bitmap(screen);
draw(test.btn_hover, test.x, test.y);
hover = 1;
break;
}
BUT, What i''m not sure about is, when the mouse ISNT hovering the bitmap, i want it to change back to it''s original bitmap. I''m not sure about this, so i ask for your help, please.
Thanks.
Dena.
Mouse-Over a Bitmap...
Hey People.
It''s me...again hehe.
In Allegro i''m trying to make a mouse-over work on a Bitmap, the mouse-over is working fine using this code..
wouldn't you just do the exact opposite?
like:
mouse_x > 230 && mouse_X < test.x
etc.
then change the pic back to the original
-btw, how do you make a code box like that? i'm new
The New N00b
[edited by - True Edge on July 25, 2003 8:19:00 PM]
like:
mouse_x > 230 && mouse_X < test.x
etc.
then change the pic back to the original
-btw, how do you make a code box like that? i'm new
The New N00b
[edited by - True Edge on July 25, 2003 8:19:00 PM]
tried that, didnt work ><
to use the code box use this.
[ source]
[ /source]
[edited by - dean1988 on July 25, 2003 8:29:21 PM]
[edited by - dean1988 on July 25, 2003 8:29:46 PM]
to use the code box use this.
[ source]
[ /source]
[edited by - dean1988 on July 25, 2003 8:29:21 PM]
[edited by - dean1988 on July 25, 2003 8:29:46 PM]
Welcome to the wonderful world of "Programming is not easy".
Have a variable like;
int ButtonState;
Then it can have values;
#define HIGHLIGHT 0
#define UP 1
#define DOWN 2
Then you can have a statement like
if(mouse over the button) ButtonState = HIGHLIGHT
if(mouse over button and clicked) ButtonState = DOWN
else ButtonState = UP
And THEN draw the button -- You could even have the buttonstate be an index into a BITMAP array so you could do something like
blit(screen, button[ButtonState],.....);
Have a variable like;
int ButtonState;
Then it can have values;
#define HIGHLIGHT 0
#define UP 1
#define DOWN 2
Then you can have a statement like
if(mouse over the button) ButtonState = HIGHLIGHT
if(mouse over button and clicked) ButtonState = DOWN
else ButtonState = UP
And THEN draw the button -- You could even have the buttonstate be an index into a BITMAP array so you could do something like
blit(screen, button[ButtonState],.....);
Using an else statement in which you set the bitmap back to the original should work. For example,
if (mouse_x==whatever && mouse_y==whatever)
{
//change current bitmap
}
else
{
//mouse is not over the bitmap, so change it back
}
"Skepticism.... that great rot of the intellect." - V.H.
Bah, what does HE know?
Albekerky Software
if (mouse_x==whatever && mouse_y==whatever)
{
//change current bitmap
}
else
{
//mouse is not over the bitmap, so change it back
}
"Skepticism.... that great rot of the intellect." - V.H.
Bah, what does HE know?
Albekerky Software
Couldn't you just do and else?
EDIT:
I just noticed this.
Shouldn't:
if (mouse_x < 230 && mouse_x > test.x && mouse_y < 190 && mouse_y > test.x && hover == 0)
Be:
if (mouse_x < 230 && mouse_x > test.x && mouse_y < 190 && mouse_y > test.y && hover == 0)
The test.x should be test.y?
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on July 25, 2003 8:37:01 PM]
if (mouse_x < 230 && mouse_x > test.x && mouse_y < 190 && mouse_y > test.x && hover == 0){ clear_bitmap(screen); draw(test.btn_hover, test.x, test.y); hover = 1; break;}else{ clear_bitmap(screen); draw(test.btn_default, test.x, test.y); hover = 0; break;}
EDIT:
I just noticed this.
Shouldn't:
if (mouse_x < 230 && mouse_x > test.x && mouse_y < 190 && mouse_y > test.x && hover == 0)
Be:
if (mouse_x < 230 && mouse_x > test.x && mouse_y < 190 && mouse_y > test.y && hover == 0)
The test.x should be test.y?
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on July 25, 2003 8:37:01 PM]
LOL else should work.
-Now someone reply to my post!
[edited by - True Edge on July 25, 2003 8:36:38 PM]
-Now someone reply to my post!
[edited by - True Edge on July 25, 2003 8:36:38 PM]
Else Statement didnt work, but i''m going to try nonnus29''s idea in the morning, i''m off to bed, Thanks for your help.
Dean.
Dean.
If else doesn''t work, then you have an error in your routine to check whether the mouse is over the bitmap, because the else part is executed when the if statement is false.
Did you fix the error UltimaX has stated??
should work to tell if the mouse cursor is outside the bitmap.
Did you fix the error UltimaX has stated??
if ((mouse_x > 230 || mouse_x < test.x) && (mouse_y > 190 || mouse_y < test.y) && hover == 1)
should work to tell if the mouse cursor is outside the bitmap.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement