[SOLVED] screen: use Vbox/displayable as imagebutton foreground

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
sandpie
Newbie
Posts: 18
Joined: Tue Apr 25, 2023 1:43 pm
Contact:

[SOLVED] screen: use Vbox/displayable as imagebutton foreground

#1 Post by sandpie »

Hi I am trying to understand how to setup a vbox as a foreground element of an imagebutton inside a screen. Renpy 8.1.3

I found that I could use a Vbox like this:

Code: Select all

	$my_vbox = VBox(image, image2)
	imagebutton auto "images/stuff/button_%s.png" foreground  my_vbox  action
It works well using two images, but I'd like to make image2 a text element:
how could I tell it to treat an argument as an image or a text (or I guess as any other displayable supported by vbox?)

Another option I tried was to init my displayable as something, but then how I tell renpy that it should be hidden (not added to scene) unless it is used as the foreground element it was meant to be?

Code: Select all

                vbox as my_vbox:
                    add image
                    text "the name"
                    
		imagebutton auto "images/stuff/button_%s.png" foreground  my_vbox  action
		
		#doing like this will add my_vbox twice because I am adding 2 children
Thank you :)
Last edited by sandpie on Sun Dec 03, 2023 12:52 pm, edited 1 time in total.

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: screen: use Vbox/displayable as imagebutton foreground

#2 Post by enaielei »

Use the Text displayable.

Code: Select all

$my_vbox = VBox(image, Text("Sample Text"))
More can be found at the Displayables section of the docs.

sandpie
Newbie
Posts: 18
Joined: Tue Apr 25, 2023 1:43 pm
Contact:

Re: [SOLVED] screen: use Vbox/displayable as imagebutton foreground

#3 Post by sandpie »

Thank you! :)

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]