How to implement a smooth style change ?

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
WladekProd
Newbie
Posts: 5
Joined: Fri Apr 05, 2024 3:48 pm
Contact:

How to implement a smooth style change ?

#1 Post by WladekProd »

Hello, I want to implement a smooth style change like in css. That-so that when you hover over the text smoothly changed the color parameter.

Example: Image

Is it possible to create a custom textbutton class for a similar task or is it easier to implement than mine ?

utils.rpy:

Code: Select all

transform smooth_button(text_color, outline_color, text_zoom, smooth_time):
    zoom text_zoom
    on idle:
        matrixcolor ColorizeMatrix(outline_color[1], text_color[1])
        linear smooth_time matrixcolor ColorizeMatrix(outline_color[0], text_color[0])
    on hover:
        matrixcolor ColorizeMatrix(outline_color[0], text_color[0])
        linear smooth_time matrixcolor ColorizeMatrix(outline_color[1], text_color[1])
screen stextbutton(text, action_func = Return(), style_class = None, smooth_time = .1, text_zoom = 1.0, text_color = [gui.selected_color, gui.hover_color_smooth], outline_color = [gui.outline_color, gui.outline_color]):
    textbutton (text) action action_func at smooth_button(text_color, outline_color, text_zoom, smooth_time):
        style style_class
screens.rpy:

Code: Select all

use stextbutton(_("Exit"), Quit(confirm=not main_menu))

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: How to implement a smooth style change ?

#2 Post by jeffster »

If you prefer creator defined displayables to ATL transforms, there are interesting examples like BGQueue and SmoothHover:
viewtopic.php?t=63219

Post Reply

Who is online

Users browsing this forum: Google [Bot]