Help on hover animation?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
LittleRainySeasons
Regular
Posts: 44
Joined: Fri Mar 24, 2017 9:37 am
Projects: Patsy n' Crinkles, Galaxy Party, Time|Reversed
Deviantart: LittleRainySeasons
Soundcloud: RoboticDreamz
itch: LittleRainySeasons
Contact:

Help on hover animation?

#1 Post by LittleRainySeasons »

Somehow I really wanted to do an animated hover and pretty much I coded it this way:

Code: Select all

image mainstart_hover:
    "mainstart_button1"
    pause .04
    "mainstart_button2"
    pause .04
    "mainstart_button3"
    pause .04
    "mainstart_button4"
    pause .04
    "mainstart_button5"
    pause .04
    "mainstart_button6"
    pause .04
    "mainstart_button7"
    pause .04
and when I placed it as an imagebutton in the menu, it won't show the animation? It only showed when I did it on repeat.

Is there a way to fix this? Also, is it possible to do an animation as well when unhovered?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help on hover animation?

#2 Post by Imperf3kt »

How did you "placed it as an imagebutton in the menu"?
What is written for the code?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
LittleRainySeasons
Regular
Posts: 44
Joined: Fri Mar 24, 2017 9:37 am
Projects: Patsy n' Crinkles, Galaxy Party, Time|Reversed
Deviantart: LittleRainySeasons
Soundcloud: RoboticDreamz
itch: LittleRainySeasons
Contact:

Re: Help on hover animation?

#3 Post by LittleRainySeasons »

Imperf3kt wrote: Thu Feb 21, 2019 2:56 am How did you "placed it as an imagebutton in the menu"?
What is written for the code?
I pretty much placed it like this

Code: Select all

imagebutton:
        idle "mainstart_idle"
        hover "mainstart_hover"
        xpos 547 ypos 453
        focus_mask True
        action Start()

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help on hover animation?

#4 Post by Imperf3kt »

You may need to use the "hovered" image attribute.

Code: Select all

imagebutton:
        idle "mainstart_idle"
        hover "mainstart_hover"
        hovered "mainstart_hover"
        xpos 547 ypos 453
        focus_mask True
        action Start()
Here's another way to apply animations within a screen (taken from an old project, I've actually updated this somewhat - this is just code from a backup but it may give you some more ideas.)

Code: Select all

screen navi_drop():
    zorder 0
    
    style_prefix "navi_drop"
    
    frame:
        at slide_vertical
        has vbox
        ysize 1178
        ymaximum 1178
        grid 1 6:
            spacing 50
            
            imagebutton alt "save" hover "gui/button/save.png" idle "gui/button/save.png" focus_mask True action ShowMenu("save"), Hide("navi_drop")
            imagebutton alt "load" hover "gui/button/load.png" idle "gui/button/load.png" focus_mask True action ShowMenu("load"), Hide("navi_drop")
            imagebutton alt "options" hover "gui/button/options.png" idle "gui/button/options.png" focus_mask True action ShowMenu("preferences"), Hide("navi_drop")
            imagebutton alt "about" hover "gui/button/about.png" idle "gui/button/about.png" focus_mask True action ShowMenu("about"), Hide("navi_drop")
            imagebutton alt "achievements" hover "gui/button/achievements.png" idle "gui/button/achievements.png" focus_mask True action ShowMenu("achievements"), Hide("navi_drop")
            imagebutton alt "main menu" hover "gui/button/main.png" idle "gui/button/main.png" focus_mask True action renpy.full_restart
    
        
transform slide_vertical:
    on show, replace:
        yanchor 1280
        linear .36 yanchor 0
    on hide, replaced:
        yanchor 0
        linear .36 yanchor 1280

style navi_drop_frame:
    background Frame(gui.main_menu_base, gui.navi_drop_frame_borders, tile=gui.frame_tile)
    padding gui.navi_drop_frame_borders.padding
    xpos 0
    ypos 102

Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
LittleRainySeasons
Regular
Posts: 44
Joined: Fri Mar 24, 2017 9:37 am
Projects: Patsy n' Crinkles, Galaxy Party, Time|Reversed
Deviantart: LittleRainySeasons
Soundcloud: RoboticDreamz
itch: LittleRainySeasons
Contact:

Re: Help on hover animation?

#5 Post by LittleRainySeasons »

Imperf3kt wrote: Thu Feb 21, 2019 4:33 am You may need to use the "hovered" image attribute.

Code: Select all

imagebutton:
        idle "mainstart_idle"
        hover "mainstart_hover"
        hovered "mainstart_hover"
        xpos 547 ypos 453
        focus_mask True
        action Start()
Here's another way to apply animations within a screen (taken from an old project, I've actually updated this somewhat - this is just code from a backup but it may give you some more ideas.)

Code: Select all

screen navi_drop():
    zorder 0
    
    style_prefix "navi_drop"
    
    frame:
        at slide_vertical
        has vbox
        ysize 1178
        ymaximum 1178
        grid 1 6:
            spacing 50
            
            imagebutton alt "save" hover "gui/button/save.png" idle "gui/button/save.png" focus_mask True action ShowMenu("save"), Hide("navi_drop")
            imagebutton alt "load" hover "gui/button/load.png" idle "gui/button/load.png" focus_mask True action ShowMenu("load"), Hide("navi_drop")
            imagebutton alt "options" hover "gui/button/options.png" idle "gui/button/options.png" focus_mask True action ShowMenu("preferences"), Hide("navi_drop")
            imagebutton alt "about" hover "gui/button/about.png" idle "gui/button/about.png" focus_mask True action ShowMenu("about"), Hide("navi_drop")
            imagebutton alt "achievements" hover "gui/button/achievements.png" idle "gui/button/achievements.png" focus_mask True action ShowMenu("achievements"), Hide("navi_drop")
            imagebutton alt "main menu" hover "gui/button/main.png" idle "gui/button/main.png" focus_mask True action renpy.full_restart
    
        
transform slide_vertical:
    on show, replace:
        yanchor 1280
        linear .36 yanchor 0
    on hide, replaced:
        yanchor 0
        linear .36 yanchor 1280

style navi_drop_frame:
    background Frame(gui.main_menu_base, gui.navi_drop_frame_borders, tile=gui.frame_tile)
    padding gui.navi_drop_frame_borders.padding
    xpos 0
    ypos 102


Oh okay, thanks!

But is there a way to do the code for the animation when it's unhovered? (Since I literally made one and I just reversed the frames of the hover animation)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help on hover animation?

#6 Post by Imperf3kt »

I think that'd be idle_selected.
Can't currently check.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users