- Nov 21, 2017
- 140
- 1,029
Is there a way to have an imagebutton go from idle image to hover image with a dissolve transition?
Thanks.
Thanks.
imagebutton auto "/gui/main_menu%s.png":
on "hovered" action With(dissolve) # <---
on "unhovered" action With(dissolve) # <---
action MainMenu()
screen myButton:
on "hovered" action With(dissolve) # <---
on "unhovered" action With(dissolve) # <---
imagebutton auto "/gui/main_menu%s.png":
action MainMenu()
screen yourScreen:
[...]
use myButton
[...]
transform PhoneButton:
on idle:
easein 0.2 alpha 0.0
on hover:
easein 0.2 alpha 1.0
screen phone_active:
image "Icon_Off.png" xalign 0.193 yalign 0.235
imagebutton:
xalign 0.193 yalign 0.235
idle "Icon_On.png"
action ui.callsinnewcontext("phone_contacts_call")
at PhoneButton
You are really precise for your alignment, so, aren'tCode:image "Icon_Off.png" xalign 0.193 yalign 0.235
Normally it shouldn't be a problem. I mean, we never heard of problems with the "hovered" button's property and there's no reason for the "on hover" thing to works differently.Only question is whether the transform should (for paranoia's sake) have an "on show" that just sets the alpha to zero, just to make sure you didn't have some spurious activation of the "on idle" transition when a screen was first shown, restored from a save or whatever. (I don't know the exact sequence of events that Renpy screens emit under all circumstances.) But if ain't broke...
That actually wasn't what I meant. My concern was that when Ren'py initially put together the screen to show it, it was probably going to set up both images with alphas of 1.0. Meaning that the "Icon_on.png" (the "hover" image) would be showing on top of the idle image. Then (possibly) Ren'py would issue an "idle" event, which might mean that you'd have an 0.2 second flicker of the "Icon_on.png" fading out just as the screen was shown. So the idea that was in my head was either to include an "on show" handler that would force the "Icon_on.png" image to 0.0 alpha immediately in that case, or possibly just to start it with alpha 0.0.Normally it shouldn't be a problem. I mean, we never heard of problems with the "hovered" button's property and there's no reason for the "on hover" thing to works differently.
To be sure that I understood this time, your meaning is : Is the transition applied before the display, in this case the "on idle" will apply from the start. Or applied after the display, in this case there's a alpha 1.0, then the "on idle". And depending on many factors (time to display the screen, charge of the computer at this time, speed of the computer), the alpha 1.0 can stay long enough to create a glitch.My concern was that when Ren'py initially put together the screen to show it, it was probably going to set up both images with alphas of 1.0. Meaning that the "Icon_on.png" (the "hover" image) would be showing on top of the idle image.
transform PhoneButton:
on show:
alpha 0.0
on idle:
easein 0.2 alpha 0.0
on hover:
easein 0.2 alpha 1.0