timy created page: Menus
parent
d7bf8f79ce
commit
18728be217
25
Menus.md
Normal file
25
Menus.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Menus
|
||||||
|
It is not too difficult to make a nice-looking menu using sprites. The general concept is to make a bunch of sprites that are “buttons.” Each of these sprites should have an OnClick event. When the player clicks on that menu item, the code in your OnClick event will fire off.
|
||||||
|
|
||||||
|
You can also use a MouseHover (to pull up a tool-tip or something)
|
||||||
|
|
||||||
|
Many people will use the “MouseEnter” and “MouseLeave” to change the animation of a menu sprite to glow, pulse, or do something when the mouse is over the button. It is just very nice to have the button react to the mouse so the user knows which button they are over at any given time.
|
||||||
|
|
||||||
|
If all your menu sprites use the same animation scheme, it might look something like: Animation 0 is the menu item by itself. Animation 1 is it with the mouse over it (glowing, etc).
|
||||||
|
|
||||||
|
Then, all your buttons can share the same mouse-enter, and mouse-leave functions.
|
||||||
|
```c#
|
||||||
|
MenuSprite.MouseEnter += spriteMouseEnter;
|
||||||
|
MenuSprite.MouseLeave += spriteMouseLeave;
|
||||||
|
|
||||||
|
void spriteMouseEnter(Sprite MenuSprite, SpriteEventArgs e)
|
||||||
|
{
|
||||||
|
MenuSprite.ChangeAnimation(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void spriteMouseLeave(Sprite MenuSprite, SpriteEventArgs e)
|
||||||
|
{
|
||||||
|
MenuSprite.ChangeAnimation(0);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Because you may sometimes have some transparent areas surrounding a menu-button, you may also want to try out the MouseEnterTransparent, MouseLeaveTransparent, and MouseHoverTransparent functions. These work the same way, except that, instead of triggering when the mouse is over the sprite rectangle, it only triggers if it is over a non-transparent area of the sprite.
|
Loading…
Reference in New Issue
Block a user