Button hover off?

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
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Button hover off?

#1 Post by Kinmoku »

Hi all,

Is it possible to have an animation play when a button is, not only hovered over, but hovered off/ unhovered? I'd like the hover image to fade out, like it fades in.

Button:

Code: Select all

            imagebutton idle "gui/auto_off.png" selected_idle "gui/auto_select.png" hover "gui/auto_on.png" clicked Preference("auto-forward", "toggle") focus_mask None at imagehover
In script.rpy:

Code: Select all

transform imagehover:
    on hover:
        alpha 0.0
        linear 1.0 alpha 1.0
        
    on hide:
        alpha 1.0
        linear 1.0 alpha 0.0
I tried "on idle" instead of "on hide" too, but it fades out when idle, as expected lol! On hide sadly does nothing.

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Button hover off?

#2 Post by DragoonHP »

I tried "on idle" instead of "on hide" too, but it fades out when idle, as expected lol! On hide sadly does nothing.
Isn't idle state just an unhovered state?

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Button hover off?

#3 Post by gas »

Set the default alpha at 0.0, then use the "on idle" event to set it back to 0.

Code: Select all

transform imagehover:
    alpha 0.0
    on hover:
        alpha 0.0
        linear 1.0 alpha 1.0
        
    on idle:
        linear 1.0 alpha 0.0
(no way of actually testing it, but it worked for me on positions and offsets).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Button hover off?

#4 Post by Kinmoku »

gas wrote: Thu Feb 20, 2020 3:11 pm Set the default alpha at 0.0, then use the "on idle" event to set it back to 0.

Code: Select all

transform imagehover:
    alpha 0.0
    on hover:
        alpha 0.0
        linear 1.0 alpha 1.0
        
    on idle:
        linear 1.0 alpha 0.0
(no way of actually testing it, but it worked for me on positions and offsets).
Sorry it took me a while to get back. It doesn't work how I want it to, which is to fade out the hover image only. This code *works* but fades out the idle image instead, so no button shows after you hover off.

When I hover off, the images switch instantly, then idle fades out. I want Idle to stay and hover to fade out. I hope this is clear ^^;

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Button hover off?

#5 Post by Kinmoku »

Any ideas on how to get this working?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]