[Solved] Possible to precisely control where textbutton goes for side screen object?

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:

[Solved] Possible to precisely control where textbutton goes for side screen object?

#1 Post by henvu50 »

EDIT: Alex's solution is best, even says so in the documentation here: 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.


EDIT: I decided to use frames instead like this:

Code: Select all

screen screen_bla():
      #use xalign yalign to position the main frame where you want on the window
      # don't forget to change the size (xsize ysize) of this frame if you notice it's not moving from xalign yalign usage.
      frame: 
            
            # space these frames by like 200 pixels using xpos and ypos    
            frame:
            
            frame:
            
            frame:

Is there anyway to control precisely where a textbutton goes for the side screen object? Like this for example?

Code: Select all

screen screen590():
    side "t tr r br b bl l tl":
        side("t"): # explicitly tell side object you want this textbutton in top position
            text "t"
        side("tr"): # textbutton goes in top right position no mater what
            text "tr"
        side("r"): 
            text "r"
        side("br"): 
            text "br"
        side("b"): 
            text "b"
        side("bl"): 
            text "bl"
        side("l"): 
            text "l"
        side("tl"): 
            text "tl"
Sometimes textbuttons maybe in certain positions, other times not. I generate textbutton's dynamically. If there's no textbutton needed for side Top for example, just leave it blank.
Last edited by henvu50 on Thu Jun 17, 2021 4:27 pm, edited 1 time in total.

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

Re: [Used Frame Instead] Possible to precisely control where textbutton goes for side screen object?

#2 Post by Alex »

henvu50 wrote: Thu Jun 17, 2021 9:04 am ...Sometimes textbuttons maybe in certain positions, other times not. I generate textbutton's dynamically. If there's no textbutton needed for side Top for example, just leave it blank.
You can set positions for each button individually. Don't need to put them inside any container (vbox/hbox/frame/fixed).
Or you can put buttons inside a container to positioning this container.
What exactly you want to achieve?

If you need a frame with buttons in it you could try:
either 'side' (as you've posted) with if's to check if it should be a button placed on or a null (to fill up all the positions set for 'side'),
or use 'fixed', set its size and align all the buttons inside it.

Code: Select all

screen screen_bla():
    frame:
        align (0.5, 0.5)
        fixed:
            xysize (500, 500)
            textbutton "Test 1" action NullAction() align(1.0, 1.0)
            textbutton "Test 2" action NullAction() align(1.0, 0.0)

Post Reply

Who is online

Users browsing this forum: Google [Bot]