Combine imagebutton and text into one button?

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
Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Combine imagebutton and text into one button?

#1 Post by Errilhl »

Is that possible?

I can think of ways to work around this, of course, like creating a button-background which is wider than the actual image (character image), and just placing the text above it, but that seems like a hackish workaround.

What I would like is for a stats-screen to work with having both an image of the character, and the name of the character, and preferably both be clickable (like it was all one button), and open the same content (stats).

Is this easily possible using an already existing imagebutton?
Currently working on: Image

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Combine imagebutton and text into one button?

#2 Post by RicharDann »

I asked a similar question some time ago:

viewtopic.php?f=8&t=45941#p466450

I went with Remix's suggestion in the end because I needed the automatic image change on hover imagebutton provides, but if your character's image doesn't need to change and you only need button functionality then using Button is also a valid option.
The most important step is always the next one.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Combine imagebutton and text into one button?

#3 Post by Remix »

The 'just stack all the stuff on top of each other in a fixed' approach, as suggested, would work fine, though you might also want to look at using text button.

From a quick 'rather untested' sleuth around the code, TextButton seems to sit on a scalable frame and actually changes the frame image on hover and unhover. It shouldn't be too tricky to track down the 'choice_button' styles in gui.rpy, make some new ones and add some hover/idle images to the game/gui folder (like the choice_ ones in there that are used for menu: blocks)
Then it would just be a case of:
... textbutton "{space=10}{image='icon.png'}{space=4}The Name{space=10}" style_prefix="whatever" action ... etc
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Sugar_and_rice