2 Attachment(s)
Easy Hover Button Example
If your style is to use hover buttons in your games / applications, this may simplify the process for you.
First, when creating your sprites (for buttons), create a dimly lit version which will be displayed when the mouse is not over the sprite. Save this as button0.png (or whatever format you use).
Create a brightly lit version of the same sprite which will be displayed only when you hover over the sprite. Save this as button1.png (again, use whatever file type you prefer).
Add a new active object to your project. Double click the active to bring up the image editor in MMF2.
Use the load function and select button0.png, and check import as animation checkbox. This way, MMF2 will load both button0.png and button1.png into frame 0 and frame 1 of your active object (the sprite).
Assign a QUALIFIER to this object. You want to use a qualifier so you can code this only once, and it will work for ALL of your hover buttons.
The attached file will show you the simple code required to make any and all of your "QUALIFIED" sprites respond to a mouse over by "lighting up".
In a nutshell, you code to test for the mouse being over the QUALIFIER, not the active object. If its over the QUALIFIER, you change the animation frame to FRAME 1 (remember, this is the second frame, since frames are counted from ZERO). You NEGATE this step to test when the cursor is NOT hovering over the button, and set frame 0 to be displayed in that case.
to prevent the continuous firing of either event, you can also test which frame is currently displayed, and only take action if needed.
Enjoy!
[color:#FF6666]EDIT: I placed the "Force Animation Frame to 0" and "Fore Animation Frame to 1" on the Qualifier, rather than the button... this way you can re-use the same qualifier for multiple objects.[/color]
Re: Easy Hover Button Example
There is a similar example of this in the Widget section. Doesn't use qualifiers, though. ;)
Button Widget by wizkidweb.
stephen1980
Re: Easy Hover Button Example
Yay I got referenced! I don't know why I'm so excited!
Re: Easy Hover Button Example
wizkidweb, I actually use your widget all the time. :) It's quite handy and underrated.
stephen1980
Re: Easy Hover Button Example
Re: Easy Hover Button Example
Well good... nice job wizkidweb, I never saw that one.
Re: Easy Hover Button Example
Was the Active Button Widget useful to anyone? I don't know. I haven't compared it to the newer one above or had any feedback on it.
Active Button Widget
Re: Easy Hover Button Example
I haven't tried that one, but I will when I get home...
Re: Easy Hover Button Example
One problem with these button widgets (and it's a big bug when using qualifier) is if the buttons are near from each other and the mouse hover one button and then hover another: all highlighted buttons will stay highlighted until the mouse cursor is not hover any button.
Re: Easy Hover Button Example
Yeah I've been trying to figure out how to fix that. I guess it can probably be fixed if all of the buttons were on one qualifier, and you set all of the buttons to the up state when a button is hovered over.
Re: Easy Hover Button Example
I just fixed that problem from the program above. move the:
X mouse is over obj.
to the top and swich the condition to "always"