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.
-
johandark
- Veteran
- Posts: 346
- Joined: Sat Apr 30, 2016 11:04 am
- Completed: Wild Guards, In Dreams
- Projects: Pact with a witch
- Deviantart: johandarkweb
- Location: Barcelona
-
Contact:
#1
Post
by johandark » Tue Jul 26, 2016 8:00 am
In the main menu buttons I would like to have one color for "idle" and another for "hover".
(But only in main menu, so in the rest of the options keep the default settings).
This is the code that works now.
Code: Select all
# The main menu buttons.
frame:
background None
style_prefix "mm"
xalign .15
yalign .39
has hbox
textbutton _("Comenzar") background None action Start()
textbutton _("Cargar partida") background None action ShowMenu("load")
textbutton _("Opciones") background None action ShowMenu("preferences")
textbutton _("Salir") background None action Quit(confirm=False)
#textbutton _("Ayuda") action Help()
I´ve tried this code:
Code: Select all
textbutton _("Comenzar") idle="#f00" hover="#fff" background None action Start()
But of course... it doesn´t work...
So... is there a right way to do it?
Thanks!
Last edited by
johandark on Thu Jul 28, 2016 12:22 pm, edited 1 time in total.
-
morg
- Regular
- Posts: 95
- Joined: Sun May 10, 2015 7:35 am
- Projects: Cupid's Affair
- Tumblr: n-morg
-
Contact:
#2
Post
by morg » Tue Jul 26, 2016 3:06 pm
add a style somewhere before start in your script
Code: Select all
style buttonz:
idle "fe3eed"
hover "d2d2d2"
insensitive "888"
background None
then assign it to your buttons like this
Code: Select all
textbutton _("Comenzar") style "buttonz" action Start()
-
johandark
- Veteran
- Posts: 346
- Joined: Sat Apr 30, 2016 11:04 am
- Completed: Wild Guards, In Dreams
- Projects: Pact with a witch
- Deviantart: johandarkweb
- Location: Barcelona
-
Contact:
#3
Post
by johandark » Tue Jul 26, 2016 3:12 pm
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/script.rpy", line 21: style property idle is not known.
idle "fe3eed"
^
Ren'Py Version: Ren'Py 6.99.10.1227

-
johandark
- Veteran
- Posts: 346
- Joined: Sat Apr 30, 2016 11:04 am
- Completed: Wild Guards, In Dreams
- Projects: Pact with a witch
- Deviantart: johandarkweb
- Location: Barcelona
-
Contact:
#4
Post
by johandark » Thu Jul 28, 2016 8:14 am
I think this shouldn´t be so complicated...
I mean... in this forum xavimat showeed me a way to put a idle and hover on imagebutton:
Code: Select all
imagebutton idle "images/menu/i_back_idle.png" hover "images/menu/i_back_hover.png" action Rollback()
Why is so complicated do the same but with textbutton and just two different colors?!
like this:
Code: Select all
textbutton idle "#fff" hover "#000" action Rollback()
But this code doesn´t work...
WHY?!
any help please?
Thanks!
-
xavimat
- Eileen-Class Veteran
- Posts: 1458
- Joined: Sat Feb 25, 2012 8:45 pm
- Completed: Yeshua, Jesus Life, Cops&Robbers
- Projects: Fear&Love, unknown
- Organization: Pilgrim Creations
- Github: xavi-mat
- itch: pilgrimcreations
- Location: Spain
-
Contact:
#5
Post
by xavimat » Thu Jul 28, 2016 12:01 pm
In imagebuttons, "idle" and "hover" ARE the buttons themselves.
Instead, in textbuttons, the button is the TEXT, and what you want is to apply properties to that text when is hovered/unhovered. That's not easy because the textbuttons are a combination of button and text, and the color of the text of a textbutton is defined in the property "text_color" and not in "color" (as it is in in the "text" element).
So, you need to define a style and apply it with "text_style" or define directly text_color (for idle) and text_hover_color (for hover):
Code: Select all
style mytextbutton:
color "#f00"
hover_color "#ff0"
screen test():
vbox:
# Using the style:
textbutton "Hello":
text_style "mytextbutton"
action NullAction()
# Formatting directly without the style:
textbutton "Hello":
text_color "#f00"
text_hover_color "#ff0"
action NullAction()
-
johandark
- Veteran
- Posts: 346
- Joined: Sat Apr 30, 2016 11:04 am
- Completed: Wild Guards, In Dreams
- Projects: Pact with a witch
- Deviantart: johandarkweb
- Location: Barcelona
-
Contact:
#6
Post
by johandark » Thu Jul 28, 2016 12:22 pm
Thank you xavimat!
Now it works!
And I even learned to create a Style! That´s nice!
Thanks!

Users browsing this forum: Bing [Bot]