Why does a screen frame ignore xalign, yalign settings if it has two objects in it?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Why does a screen frame ignore xalign, yalign settings if it has two objects in it?

#1 Post by henvu50 »

As soon as you put two objects in this frame, the xalign & yalign stop working, why is that?!

Code: Select all

screen test8943():
    frame:
        xalign 0.5
        yalign 0.5
        background None
        textbutton "why12323":
            action NullAction()
        imagebutton:
            idle "a1_idle.png"
            hover "a1_hover.png"
            focus_mask True
            action Jump("dfadf")```
I hate screens so much. This is such a waste of time. I shoudl be able to make a screen in a GUI interface in like 2 minutes, and then BE DONE with it. Instead, making screens goes from minutes to HOURS. what a waste of time.

laure44
Regular
Posts: 84
Joined: Mon Mar 08, 2021 10:55 pm
Projects: Arkan'sTower, Gemshine Lorelei!
Location: France
Contact:

Re: Why does a screen frame ignore xalign, yalign settings if it has two objects in it?

#2 Post by laure44 »

I would suggest using vbox or hbox instead.

Code: Select all

screen test8943():
    vbox:
        xalign 0.5
        yalign 0.5
        textbutton "why12323":
            action NullAction()
        imagebutton:
            idle "a1_idle.png"
            hover "a1_hover.png"
            focus_mask True
            action Jump("dfadf")
But if you need the elements to overlap, you can also use fixed

Code: Select all

screen test8943():
    fixed:
        xalign 0.5 yalign 0.5
        xfit True yfit True
        imagebutton:
            idle "a1_idle.png"
            hover "a1_hover.png"
            focus_mask True
            action Jump("dfadf")
        textbutton "why12323":
            action NullAction()

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Why does a screen frame ignore xalign, yalign settings if it has two objects in it?

#3 Post by Alex »

henvu50 wrote: Thu Jun 17, 2021 5:04 am As soon as you put two objects in this frame, the xalign & yalign stop working, why is that?! ...
Maybe 'cause it should have one child - https://www.renpy.org/doc/html/screens.html#frame

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Why does a screen frame ignore xalign, yalign settings if it has two objects in it?

#4 Post by henvu50 »

Alex wrote: Thu Jun 17, 2021 4:01 pm
henvu50 wrote: Thu Jun 17, 2021 5:04 am As soon as you put two objects in this frame, the xalign & yalign stop working, why is that?! ...
Maybe 'cause it should have one child - https://www.renpy.org/doc/html/screens.html#frame
It takes one child. If zero, two, or more children are supplied, then a fixed is created to contain them.


i missed that part, thanks!

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot], Ocelot