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.
-
mark_lenders
- Newbie
- Posts: 2
- Joined: Wed Jan 06, 2021 2:08 pm
-
Contact:
#1
Post
by mark_lenders » Wed May 11, 2022 6:57 pm
Hi, renpy noob here
to avoid making multiple images for my game, I'm trying to handle buttons using a single background image and adding text to it from variables
textbutton failed me (it almost works but doesn't handle hover) as well as imagebutton (i can't add text) but I made it work with the following code
Code: Select all
fixed:
xysize (200, 40)
imagebutton auto "mybutton_%s.png"
text "whatever" style "mybutton_text"
This portion of code will be repeated multiple times, so i'd like to define it as "mybutton(txt)" so in the future I will have to change the text style or the background image only once in the code
My problem is that I don't know if renpy allows this nor which syntax to use... I also couldn't find any example online
Any help will be greatly appreciated
-
Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#2
Post
by Ocelot » Wed May 11, 2022 7:20 pm
What is wrong with just
button with a background containig text?
Scratch that, what is wrong with textbutton containing several alternative backgrounds?
Page on style properties gives an example on how to use them:
https://www.renpy.org/doc/html/style_properties.html
< < insert Rick Cook quote here > >
-
Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
-
Contact:
#3
Post
by Imperf3kt » Thu May 12, 2022 9:40 am
I use imagebuttons in this way.
What you need is
Code: Select all
hover_foreground Text(_("Your text here"))
idle_foreground Text(_("Your text here"))
You can further customise this with something like this
Code: Select all
hover_foreground Text(_("Your text here"), xalign=0.5, yalign=0.5, style="your style")
idle_foreground Text(_("Your text here"), xalign=0.5, yalign=0.5, style="your style")
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project:
GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
-
mark_lenders
- Newbie
- Posts: 2
- Joined: Wed Jan 06, 2021 2:08 pm
-
Contact:
#4
Post
by mark_lenders » Thu May 12, 2022 3:47 pm
Ocelot wrote: ↑Wed May 11, 2022 7:20 pm
What is wrong with just
button with a background containig text?
Scratch that, what is wrong with textbutton containing several alternative backgrounds?
Page on style properties gives an example on how to use them:
https://www.renpy.org/doc/html/style_properties.html
what's wrong with that? absolutely nothing! i just couldn't find the "hovered_background" tag with my googling
thanks!
Users browsing this forum: Bing [Bot], Google [Bot], minyan