[Solved] Vertical/Rotated text on a screen

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
Cristiander
Regular
Posts: 33
Joined: Sat Mar 04, 2017 8:19 am
Contact:

[Solved] Vertical/Rotated text on a screen

#1 Post by Cristiander » Sat Oct 13, 2018 3:12 pm

Hello.
Simple question. How can you rotate text on a screen? I've searched online but I've only seen solutions for rotating images, solutions that didn't work for text.
I tried adding the text with a transform

Code: Select all

text "Test:
xalign 0.5
rotate 90
But this gives me an error, claiming that the rotate argument is not valid for text statements.

I tried adding the text to it's own separated frame or hbox or vbox, but again I get the error saying that the rotate argument doesn't work for frames/hboxes/vboxes.

I tried adding the Text as an image

Code: Select all

image perst_text = Text(pers,xalign=0.5, rotate = 90)
But it didn't work (and i'm not sure if it could work)

I've been struggling with this problem for about an hour with little success.
I'm sure I'm just missing something simple, but I really can't find it.
Any help is appreciated. Thank you :)
Last edited by Cristiander on Sun Oct 14, 2018 10:30 am, edited 2 times in total.

TakeHomeTheCup
Newbie
Posts: 15
Joined: Tue Oct 09, 2018 9:12 pm
Contact:

Re: Rotate the text of a screen

#2 Post by TakeHomeTheCup » Sat Oct 13, 2018 6:06 pm

Try:

Code: Select all

        transform:
            rotate 25
            text "Hello world"

User avatar
xavimat
Eileen-Class Veteran
Posts: 1336
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Rotate the text of a screen

#3 Post by xavimat » Sun Oct 14, 2018 6:44 am

There are style-properties, used in screens, and transform-properties, used in ATL.
"rotate" is not a style-property, is a transform-property. This can be confusing because "xpos" or "yalign", for example, are used in styles and in transforms, so one could assume that every property can be used in both, and that's not true.

In your case, you can create a transform and apply it to the text on the screen with "at".

Code: Select all

transform myrotate:
    rotate 15

screen myscreen():
    text "Hello world!" at myrotate
Note that "rotate" is tricky, many times the rotated element falls outside the screen. You may need to set also rotate_pad, and other rotate-related properties in the transform.
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
unknown [Sci-Fi - mystery - computer]
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Cristiander
Regular
Posts: 33
Joined: Sat Mar 04, 2017 8:19 am
Contact:

Re: Rotate the text of a screen

#4 Post by Cristiander » Sun Oct 14, 2018 10:14 am

TakeHomeTheCup wrote:
Sat Oct 13, 2018 6:06 pm
Try:

Code: Select all

        transform:
            rotate 25
            text "Hello world"
I tried it and it worked, however if I changed the text it would have moved on the X axis. It never stood still.
The problem is that my text needs to change length (Sometimes I want it to show a short word, sometimes a long word) and because of this the length of the text transform was changing as well and so the text was never centered.

xavimat wrote:
Sun Oct 14, 2018 6:44 am
There are style-properties, used in screens, and transform-properties, used in ATL.
"rotate" is not a style-property, is a transform-property. This can be confusing because "xpos" or "yalign", for example, are used in styles and in transforms, so one could assume that every property can be used in both, and that's not true.

In your case, you can create a transform and apply it to the text on the screen with "at".

Code: Select all

transform myrotate:
    rotate 15

screen myscreen():
    text "Hello world!" at myrotate
Note that "rotate" is tricky, many times the rotated element falls outside the screen. You may need to set also rotate_pad, and other rotate-related properties in the transform.
I didn't get to try your solution, since I was able to find something else, but thank you. If I need to place text at a 45 or 30 degree angle I'll give it a shot. :)



In the end I didn't need a custom angle for my text, I just needed it to be vertical, but because the vertical argument didn't rotate the letters I thought that the only way to create vertical text was by rotating it.
So for future reference, if anyone needs this:

Code: Select all

            $ var_array = "{horiz=True}" + array_for_text[array_id] + "{/horiz}"
            text var_array:
                xpos 0.5
                xanchor 0.5
                vertical True
The vertical style propriety can be added to text to render it vertically, and then you can add the text tag horiz to rotate the letters.
In my case however the text that I needed to be rotated was in an array, so I had to create an additional variable that added the horiz text tag and my array together.

And now it works ^_^

Post Reply

Who is online

Users browsing this forum: No registered users