[Solved] Centering text vertically?

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
shwippie
Regular
Posts: 129
Joined: Wed Dec 22, 2010 4:12 pm
Completed: Double Romance
Projects: Rolland's Candy Shop. Mitzi's Fable
Tumblr: shwippie
Deviantart: shwippie
Contact:

[Solved] Centering text vertically?

#1 Post by shwippie »

Hello! I'm having trouble centering text inside the textbox vertically in the newest version of Ren'Py. The instructions say to use 0.5 to center, but it doesn't appear to work if I use yalign, and if I use ypos, it moves it to 0.5 pixels instead of centering it. If I try using only yalign and delete ypos, I get an error. This is what the code looks like:

Code: Select all

## The placement of dialogue relative to the textbox. These can be a whole
## number of pixels relative to the left or top side of the textbox, or 0.5 to
## center.
define gui.text_xpos = 300
define gui.text_ypos = 60 
define gui.text_yalign = 0.5

## The maximum width of dialogue text, in pixels.
define gui.text_width = 790

## The horizontal alignment of the dialogue text. This can be 0.0 for left-
## aligned, 0.5 for centered, and 1.0 for right-aligned.
define gui.text_xalign = 0.0
This is what the result looks like. I'd like it to be centered vertically, whether it's one line or three lines of text. It currently only looks centered when there are two lines of text. Thank you for any help!

Image
Last edited by shwippie on Mon Oct 03, 2016 3:41 pm, edited 1 time in total.
Image Image Image

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Centering text vertically?

#2 Post by Ocelot »

Check say_dialogue style. It is defined after say screen in screens.rpy.

Default definition is:

Code: Select all

style say_dialogue:
    xpos gui.text_xpos
    xanchor gui.text_xalign
    xsize gui.text_width
    ypos gui.text_ypos

    text_align gui.text_xalign
    layout ("subtitle" if gui.text_xalign else "tex")
You want to remove ypos line and replave it with yalign 0.5
< < insert Rick Cook quote here > >

shwippie
Regular
Posts: 129
Joined: Wed Dec 22, 2010 4:12 pm
Completed: Double Romance
Projects: Rolland's Candy Shop. Mitzi's Fable
Tumblr: shwippie
Deviantart: shwippie
Contact:

Re: Centering text vertically?

#3 Post by shwippie »

Ocelot wrote: You want to remove ypos line and replave it with yalign 0.5
Thank you, Ocelot! This worked!

Although, it looks weird now that it works :shock: Maybe I should switch back

Post Reply

Who is online

Users browsing this forum: Google [Bot]