vbox problem. Number of buttons change placement. [SOLVED]

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
User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

vbox problem. Number of buttons change placement. [SOLVED]

#1 Post by Luxliev »

I've got problem with vbox whenever I add new button everything goes slightly higher. Is this intended? Can I keep it at the same height no matter how many buttons there are? Below you have code and screenshots showing problem

Code: Select all

    hbox align (1.0,0.0):
        textbutton "Close Research" action [ Hide("research_screen"), Show("research_button")]
        vbox align (0.7162,0.122):
            textbutton "[fusion_bomb.name]" action [SetVariable("researching", fusion_bomb), Hide("research_screen"), Show("research_button")]
            textbutton "[other.name]" action [SetVariable("researching", other), Hide("research_screen"), Show("research_button")]
How does it look like in game
Image
More buttons in vbox:

Code: Select all

    hbox align (1.0,0.0):
        textbutton "Close Research" action [ Hide("research_screen"), Show("research_button")]
        vbox align (0.7162,0.122):
            textbutton "[fusion_bomb.name]" action [SetVariable("researching", fusion_bomb), Hide("research_screen"), Show("research_button")]
            textbutton "[other.name]" action [SetVariable("researching", other), Hide("research_screen"), Show("research_button")]
            textbutton "[other.name]" action [SetVariable("researching", other), Hide("research_screen"), Show("research_button")]
            textbutton "[other.name]" action [SetVariable("researching", other), Hide("research_screen"), Show("research_button")]
            textbutton "[other.name]" action [SetVariable("researching", other), Hide("research_screen"), Show("research_button")]
            textbutton "[other.name]" action [SetVariable("researching", other), Hide("research_screen"), Show("research_button")]
How does it look like in game:
Image
Last edited by Luxliev on Mon Mar 23, 2015 8:55 am, edited 1 time in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

ForklessAnon
Regular
Posts: 49
Joined: Fri Sep 06, 2013 1:13 am
Contact:

Re: vbox problem. Number of buttons change placement.

#2 Post by ForklessAnon »

When using the align property, both the pos and anchor values are set to that value. If you want to keep it at the same height, you'll need to set the second value in the vbox align tuple to either a specific pixel amount or set it to 0.0 which guarantees the anchor to be set at the very top. Using align makes the displayables center themselves according to the value given. If it's a float, it's treated as a percentage based on it's height. (0.5 is exact center, 0.25 is partial center on the top half, etc.)

I'm also pretty sure that you can replace the Show(),Hide() bit with just a renpy.restart_interaction reference for the action to call to.

My suggestion:

Code: Select all

hbox:
    align (1.0,0.0)
    textbutton "Close Research" action Hide("research_screen")
    vbox:
        xalign 0.7162
        ypos 0.0 #change this value to move the buttons to the desired vertical placement
        textbutton "[fusion_bomb.name]" action [SetVariable("researching", fusion_bomb), renpy.restart_interaction]
        textbutton "[other.name]" action [SetVariable("researching", other), renpy.restart_interaction]
so if my assumptions are correct, that should fix the issue.

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: vbox problem. Number of buttons change placement.

#3 Post by Luxliev »

Thanks! Placement problem solved. When I used renpy.restart_interaction nothing happens after clicking button. Maybe I'm doing something wrong. Anyway position of button fixed.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]