Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Dean1988

Mouse-Over a Bitmap...

This topic is 5540 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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..
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.

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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],.....);

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Couldn't you just do and else?


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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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??


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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!