Snippets

SinnyStar [Ren'Py] Animated displayable upon hovering over a button

Created by Sinny Star
screen main_menu():
    # The background of the game menu.
    window:
        style "mm_root"

    # This ensures that any other menu screen is replaced.
    tag menu

    # Create a variable for each shadow's state
    default sh_start = __main_menu_button_idle
    default sh_continue = __main_menu_button_idle
    default sh_options = __main_menu_button_idle
    default sh_quit = __main_menu_button_idle

    add "gui/menu-button-newgame_shadow.png" id "newgame_shadow" xcenter .50 ycenter .42 at sh_start
    add "gui/menu-button-continue_shadow.png" id "continue_shadow" xcenter .50 ycenter .57 at sh_continue     
    add "gui/menu-button-options_shadow.png" id "options_shadow" xcenter .50 ycenter .72 at sh_options
    add "gui/menu-button-quit_shadow.png" id "quit_shadow" xcenter .50 ycenter .87 at sh_quit
        
    imagebutton auto "gui/menu-button-newgame_%s.png" action Start('_game_start_setup') xcenter .50 ycenter .42 at __main_menu_button hovered [SetScreenVariable("sh_start",__main_menu_button_hover)] unhovered [SetScreenVariable("sh_start",__main_menu_button_idle)]
    imagebutton auto "gui/menu-button-continue_%s.png" action ShowMenu("load") xcenter .50 ycenter .57 at __main_menu_button hovered [SetScreenVariable("sh_continue",__main_menu_button_hover)] unhovered [SetScreenVariable("sh_continue",__main_menu_button_idle)]
    imagebutton auto "gui/menu-button-options_%s.png" action ShowMenu("options") xcenter .50 ycenter .72 at __main_menu_button hovered [SetScreenVariable("sh_hover",__main_menu_button_hover)] unhovered [SetScreenVariable("sh_options",__main_menu_button_idle)]
    imagebutton auto "gui/menu-button-quit_%s.png" action Quit(confirm=False) xcenter .50 ycenter .87 at __main_menu_button hovered [SetScreenVariable("sh_quit",__main_menu_button_hover)] unhovered [SetScreenVariable("sh_quit",__main_menu_button_idle)]

init -2:
    transform __main_menu_button:
        on idle:
            easein 0.5 zoom 1.0
        on hover:
            easein 0.3 zoom 1.2
    transform __main_menu_button_idle:
        easein 0.5 xoffset 0 yoffset 0
    transform __main_menu_button_hover:
        easein 0.3 xoffset 50 yoffset 50

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.