xcenter and ycenter commands not working; screen goes awry.

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
traceExcalibur
Newbie
Posts: 4
Joined: Wed May 27, 2015 3:43 pm
Contact:

xcenter and ycenter commands not working; screen goes awry.

#1 Post by traceExcalibur »

Hello! I'm working on some inventory menus for a project, and the xcenter and ycenter commands aren't working right. I want an info screen to pop-up when the user clicks to examine an item in their inventory, and I'd like it to be centered. Here's how it currently looks without xcenter and ycenter:

Image

And now with xcenter and ycenter:

Image

As you can see, they're flinging the screen off to the upper-left instead of centering it like they're supposed to. I'm finding the same issue if I try to use xalign and yalign instead. Not sure why it would be happening. Included below is all the code I'm using for the screen:

Code: Select all

screen item_view(inventory, item):
    
    #frame contains all sections of item popup
    #and background
    
    frame:
        
        xcenter
        ycenter
        
        left_padding 0
        top_padding 0
        
        background "item_view.png"
        
            #name of item
            
        fixed:

            
            xpos 16 ypos 16
            xoffset 4
            yoffset 4
            
            xminimum 704   xmaximum 704
            yminimum 64  ymaximum 64
            
            
            text "[item[0].name]" font "bandmess.ttf" size 54 line_leading 0 outlines [(0, "160B02", 5, 5),(3, "000000", 0, 0)]
            
            #qty of item
            
        fixed:
            
            xpos 716 ypos 16
            
            xminimum 90 xmaximum 90
            yminimum 64 ymaximum 64
            
            text "x[item[1]]" font "bandmess.ttf" size 54 line_leading 4 text_align 1.0 outlines [(0, "160B02", 5, 5),(3, "000000", 0, 0)]
            
            #item icon
            
        fixed:
            
            xpos 16 ypos 96
            
            #attempts to load icon for the item being displayed
            #if there is no icon available, loads a more generic backup icon instead
            
            if item[0].icon:
                
                python:
        
                    if renpy.loadable(item[0].icon):
                        dispimage = item[0].icon
                    
                    else:
                        dispimage = item[0].backupicon
                
                image dispimage
                
            #full flavor text for item
            
        fixed:
            
            xpos 288 ypos 96
            xmaximum 480 ymaximum 144
            xoffset 12
            yoffset 8
            
            text "[item[0].fulldesc]" size 20 outlines [(2, "000000", 0, 0)]
            
            #describes the item's effect
            
        fixed:
            
            xpos 16 ypos 386
            xmaximum 240 ymaximum 64
            #xcenter
            #ycenter
            
            text "[item[0].effectdesc]" size 16 outlines [(2, "000000", 0, 0)]
            
            # trade, combat, and food values
            
        fixed:
            
            xpos 288 ypos 256
            xmaximum 256 ymaximum 176
            xoffset 12
            yoffset 8
            
            vbox:
                
                hbox:
                    
                    text "TRADE VALUE:" size 20 outlines [(2, "000000", 0, 0)]
                    text "[item[0].value]" size 20 outlines [(2, "000000", 0, 0)]
            
                hbox:
                    
                    text "COMBAT VALUE:" size 20 outlines [(2, "000000", 0, 0)]
                    text "[item[0].comvalue]" size 20 outlines [(2, "000000", 0, 0)]
                    
                    
                hbox:
                    
                    text "FOOD VALUE:" size 20 outlines [(2, "000000", 0, 0)]
                    text "[item[0].nutvalue]" size 20 outlines [(2, "000000", 0, 0)]
                    
            # list of crafting types
            
        fixed:
            
            xpos 560 ypos 256
            xmaximum 224 ymaximum 176
            xoffset 12 yoffset 8
            
            vbox:
                
                for crafttype in item[0].crafttypes:
                    
                    text "[crafttype]" size 20 outlines [(2, "000000", 0, 0)]
Any ideas? Am I doing something wrong, or is there a bug with xcenter and ycenter?

User avatar
kitsalai
Regular
Posts: 65
Joined: Wed Jan 08, 2014 11:05 pm
Projects: Imaginatum
Location: US
Contact:

Re: xcenter and ycenter commands not working; screen goes aw

#2 Post by kitsalai »

Did you copy and paste your code directly? If so, there's a typo when using xcenter and ycenter as they require a parameter. It should be xcenter 0.5 and ycenter 0.5 if you want them aligned in the center of the screen.
http://www.renpy.org/doc/html/atl.html# ... ty-xcenter

traceExcalibur
Newbie
Posts: 4
Joined: Wed May 27, 2015 3:43 pm
Contact:

Re: xcenter and ycenter commands not working; screen goes aw

#3 Post by traceExcalibur »

kitsalai wrote:Did you copy and paste your code directly? If so, there's a typo when using xcenter and ycenter as they require a parameter. It should be xcenter 0.5 and ycenter 0.5 if you want them aligned in the center of the screen.
http://www.renpy.org/doc/html/atl.html# ... ty-xcenter
Ah, I totally missed that when reading the docs; I assumed all I had to do was pop in xcenter and ycenter with no values.

That said, using xcenter 0.5 and ycenter 0.5 doesn't seem to change the position at all; the screen remains with its upper-left corner at (0, 0) like in the first image.

User avatar
kitsalai
Regular
Posts: 65
Joined: Wed Jan 08, 2014 11:05 pm
Projects: Imaginatum
Location: US
Contact:

Re: xcenter and ycenter commands not working; screen goes aw

#4 Post by kitsalai »

One thing that might help is specifying the xysize. For instance, xysize 600, 400. Or xmaximum and xminimum if you want.

traceExcalibur
Newbie
Posts: 4
Joined: Wed May 27, 2015 3:43 pm
Contact:

Re: xcenter and ycenter commands not working; screen goes aw

#5 Post by traceExcalibur »

kitsalai wrote:One thing that might help is specifying the xysize. For instance, xysize 600, 400. Or xmaximum and xminimum if you want.
Aha! That's what I was missing; I specified the size and now it works properly. Thank you so much for the help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot]