How can I bind text and image together?

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
apoto
Newbie
Posts: 22
Joined: Thu Apr 26, 2018 11:32 am
Contact:

How can I bind text and image together?

#1 Post by apoto »

I'm Trying to make a button with text and image but I keep failing

Code: Select all

image text_start:
    text _("Begin"):
        size 28
        font"SourceHanSerifSC-Heavy.otf"
        color"#FFFFFF"
image button_start = Composite(
    (216, 82),
    (0,0), "gui/launch_page/button.png",
    (54,30), "text_start")

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: How can I bind text and image together?

#2 Post by Imperf3kt »

Use an imagebutton and add text to the foreground states

Code: Select all

screen my_screen() :
    fixed:
        imagebutton:
            idle "gui/launch_page/button.png" 
            hover "gui/launch_page/button.png" 
            idle_foreground Text("{size=28}{font=SourceHanSerifSC-Heavy.otf}Begin{/font}{/size}" , xalign=0.5, yalign=0.5)
            hover_foreground Text("{size=28}{font=SourceHanSerifSC-Heavy.otf}Begin{/font}{/size}" , xalign=0.5, yalign=0.5)
            action Start() 
I'd suggest using a style though instead of inline styles.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
apoto
Newbie
Posts: 22
Joined: Thu Apr 26, 2018 11:32 am
Contact:

Re: How can I bind text and image together?

#3 Post by apoto »

Imperf3kt wrote: Sun May 26, 2019 4:42 am Use an imagebutton and add text to the foreground states

Code: Select all

screen my_screen() :
    fixed:
        imagebutton:
            idle "gui/launch_page/button.png" 
            hover "gui/launch_page/button.png" 
            idle_foreground Text("{size=28}{font=SourceHanSerifSC-Heavy.otf}Begin{/font}{/size}" , xalign=0.5, yalign=0.5)
            hover_foreground Text("{size=28}{font=SourceHanSerifSC-Heavy.otf}Begin{/font}{/size}" , xalign=0.5, yalign=0.5)
            action Start() 
I'd suggest using a style though instead of inline styles.
Thank you very much!!!!

Post Reply

Who is online

Users browsing this forum: Google [Bot]