Page 1 of 1

How can I bind text and image together?

Posted: Sat May 25, 2019 11:30 pm
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")

Re: How can I bind text and image together?

Posted: Sun May 26, 2019 4:42 am
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.

Re: How can I bind text and image together?

Posted: Sun May 26, 2019 12:49 pm
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!!!!