Code: Select all
frame:
xalign 0.5
yalign 0.5
xmaximum 400
ymaximum 400
textbutton "Click me":
xpos 30
ypos 30
text_size 30
Code: Select all
frame:
xalign 0.5
yalign 0.5
xmaximum 400
ymaximum 400
textbutton "Click me":
xpos 30
ypos 30
text_size 30
Code: Select all
frame:
xalign 0.5
yalign 0.5
xmaximum 400
ymaximum 400
textbutton "Click me":
xpos 30
ypos 30
text_size 30
text_align 0.5
Code: Select all
style textbutton_text:
xpos 30
ypos 30
text_size 30
text_align 0.5
Code: Select all
frame:
style "textbutton"
xalign 0.5
yalign 0.5
xmaximum 400
ymaximum 400
textbutton "Click me" action Jump("Upstairs")
Code: Select all
screen test:
frame:
xalign 0.5
yalign 0.5
xmaximum 400
ymaximum 400
textbutton "Click me":
text_size 30
background "images/a.png"
text_align 0.5
text_color "#000"
label start:
show screen test
"testing"
so you don't understand what Imperf3kt and I said then you have start learning python we have told how to do it but you not listeningnewbiemate wrote: ↑Fri May 29, 2020 8:38 pm @rayminator sorry that was a typo, but the problem still persists. If you run that same code on your end, do you see the same issue?
Also here is the button image, if anyone wants to try it out: a.png
Code: Select all
textbutton "Click me":
text_size 30
background "images/a.png"
text_align 0.5
text_color "#000"
Code: Select all
style textbutton:
xpos 30
ypos 30
text_align 0.5
screen test:
frame:
textbutton "Click me":
style "textbutton"
xalign 0.5
yalign 0.5
text_size 30
background "images/a.png"
label start:
show screen test
"testing"
Code: Select all
screen test:
frame:
xalign 0.5
yalign 0.5
xmaximum 200
ymaximum 50
textbutton "Click me":
xpos 30
ypos 30
text_size 30
text_align 0.5
background "images/a.png"
label start:
show screen test
"testing"
Code: Select all
textbutton "Click me":
xpos 30
ypos 30
xysize (200, 50)
text_size 30
text_align (0.5, 0.5)
background "images/a.png"
You shouldn't need to do it like that.MaydohMaydoh wrote: ↑Sat May 30, 2020 1:03 pm Also text_align is wrong. Textbutton itself doesn't take text_align property. It also only positions the text within the text displayable not the container. What you want is to give the align property to the text, which in this case, is also text_align.Code: Select all
textbutton "Click me": xpos 30 ypos 30 xysize (200, 50) text_size 30 text_align (0.5, 0.5) background "images/a.png"
. Which has a link to https://www.renpy.org/doc/html/screens.html#texttext_-
Other properties prefixed with text have this prefix stripped, and are then passed to the text displayable
Code: Select all
button: # a generic button that just acts as a container for any displayables
align (.5, .5) # this aligns the button centrally within the container
has fixed # use an explicit fixed so we can shrinkwrap the children
fit_first True # this shrinks the fixed from taking as much space as possible, to only being the size of it's first child
add 'images/a.png' # the first child, the background image
text 'Click me please!': # the text becomes the second child
align (.5, .5) # this aligns the text disp centrally within the fixed
color '000'
size 25 # lowered to demonstrate text wrapping
text_align 0.5 # this ensures the text is aligned centrally within the text displayable itself (i.e. when wrapping)
Code: Select all
# The four numerical arguments are pixels from each edge to be preserved, as the example image is a solid color, zero will suffice.
# If using a solid colour in production, then using a Solid displayable would be preferred, this is left as an exercise for the reader.
image bg = Frame('images/a.png', 0, 0, 0, 0)
Code: Select all
textbutton 'Click me!':
background 'bg' # the frame we just defined
align (.5, .5) # this aligns the textbutton centrally within the container
text_color '000'
text_size 30
text_align 0.5 # this ensures the text is aligned centrally within the text displayable itself (i.e. when wrapping)
Code: Select all
image bg = Frame('images/a.png', 0, 0, 0, 0)
screen example():
button: # a generic button that just acts as a container for any displayables
align (.5, .4) # this aligns the button centrally within the container
has fixed # use an explicit fixed so we can shrinkwrap the children
fit_first True # this shrinks the fixed from taking as much space as possible, to only being the size of it's first child
add 'images/a.png' # the first child, the background image
text 'Click me!': # the text becomes the second child
align (.5, .5) # this aligns the text disp centrally within the fixed
color '000'
size 30
text_align 0.5 # this ensures the text is aligned centrally within the text displayable itself (i.e. when wrapping)
textbutton 'Click me!':
background 'bg' # the frame we just defined
align (.5, .6) # this aligns the textbutton centrally within the container
text_color '000'
text_size 30
text_align 0.5 # this ensures the text is aligned centrally within the text displayable itself (i.e. when wrapping)
Users browsing this forum: No registered users