pos properties for elements of fixed displayable [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
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

pos properties for elements of fixed displayable [solved]

#1 Post by saguaro »

I cannot figure out how to set xalign and yalign for fixed displayable alphablend. I was able to align the text displayable using it's own positional arguments, but alphablend doesn't take pos.

Something like Fixed(img, img2, xalign=0.5, yalign=0.5, xysize=(326,217)) doesn't work, but the documentationleads me to believe it should?

I found a workaround by using livecomposite to manually center the alphablend image, but that seems kinda hacky. I wondered if I'm missing something? This is not super critical obviously I just want some education.

Code: Select all

screen file_picker(current_screen, trans):
    frame:

        ...

            # Display ten file slots, numbered 1 - 10.
            for i in range(1, columns * rows + 1):
                $ num = "% 2s" % FileSlotName(i, columns * rows)  
                $ ss = AlphaBlend("images/save-file-alpha.png",Solid("#0000"), LiveCrop((95,45,300,200),FileScreenshot(i)), alpha=True)

                # Each file slot is a button.
                button:
                    action FileAction(i)  
                    
                    idle_background Fixed(Null(width=326, height=217), ss, Text(str(num), color=(255,255,255,80), size=200, xalign=0.35), xalign=0.5, yalign=0.5, xysize=(326,217))
                    
                    selected_idle_background Fixed(LiveComposite((326,217), (0,0), "images/gui/game_selected.png", (13,8), ss), Text(str(num), color=(255,255,255,80), size=200, xalign=0.35), xalign=0.5, yalign=0.5, xysize=(326,217))
                    
                    hover_background Fixed(LiveComposite((326,217), (0,0), "images/gui/game_hover.png", (13,8), ss), Text(str(num), color=("#FFF"), size=200, xalign=0.35), xalign=0.5, yalign=0.5, xysize=(326,217))
Last edited by saguaro on Mon Aug 18, 2014 9:08 pm, edited 3 times in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: positional properties for elements of fixed displayable

#2 Post by xela »

It's hard to understand what you're trying to do (exactly) but you could try putting Solid into a Frame and see if Composite is still required than.
Like what we're doing? Support us at:
Image

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: positional properties for elements of fixed displayable

#3 Post by saguaro »

I am trying to create a fixed displayable that centers all elements within itself.

I cannot position image ss without livecomposite, as far as I can tell, because it is an alphablend and alphablend does not take a pos argument. Even if the fixed also includes a background image sized (326,217), a null, a solid, whatever... the various image elements all automatically align 0,0.. fixed just stacks them all into the top left corner.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: positional properties for elements of fixed displayable

#4 Post by xela »

I cannot follow :(

My AlphaBlend take pos arguments just fine, I can place it anywhere I like in a screen or inside of another displayable as long as I've created the AB correctly. I expected Solid in your AB to be a culprit of dispositioning because it doesn't have proper bounds.

If it isn't, I don't know what else to suggest unless you want to upload isolated code with images.
Like what we're doing? Support us at:
Image

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: positional properties for elements of fixed displayable

#5 Post by saguaro »

sorry, i added more of the code above if anyone else wants to take a shot at it, this is for a screenshot button on the save/load screen

the xalign=0.5, yalign=0.5, listed in the fixed displayable does nothing

alphablend only takes 3 arguments, at least the way i'm using it

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: positional properties for elements of fixed displayable

#6 Post by xela »

saguaro wrote:sorry, i added more of the code above if anyone else wants to take a shot at it, this is for a screenshot button on the save/load screen

the xalign=0.5, yalign=0.5, listed in the fixed displayable does nothing

alphablend only takes 3 arguments, at least the way i'm using it
It takes 4 the way you're using it but that's beside the point.

I cannot test that exact code as I lack the images. All I can tell you that I can position my AlphaBlends inside Fixed or any other container without any issues, using aling, pos, anchor, offset or any combination. Your statement that AlphaBlend doesn't take pos is not true, rest is up to you to figure out.
Like what we're doing? Support us at:
Image

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: positional properties for elements of fixed displayable

#7 Post by saguaro »

All right, so it behaves as expected for other people I've just messed it up somewhere. I'll keep working with it. Thanks for trying to help me understand.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: positional properties for elements of fixed displayable

#8 Post by xela »

saguaro wrote:All right, so it behaves as expected for other people I've just messed it up somewhere. I'll keep working with it. Thanks for trying to help me understand.

Code: Select all

                button:
                    xysize (326, 217)
                    align (0.5, 0.5)
                    action FileAction(i) 
                   
                    idle_background Fixed(Transform(ss, pos=(13, 8)), Text(str(num), color=(255,255,255,80), size=200, xalign=0.35))
                    selected_idle_background Fixed("images/gui/game_selected.png", Transform(ss, pos=(13, 8)), Text(str(num), color=(255,255,255,80), size=200, xalign=0.35))
                    hover_background Fixed("images/gui/game_hover.png", Transform(ss, pos=(13, 8), Text(str(num), color=("#FFF"), size=200, xalign=0.35))
Try something like this, it might work, I obviously cannot test it.
Like what we're doing? Support us at:
Image

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: positional properties for elements of fixed displayable

#9 Post by saguaro »

Transform absolutely does work! I didn't even know about that function, thank you very much, it will be useful for other stuff as well no doubt.

I tested with solid displayables of the same dimensions just to see if my images were the problem, but Transform is still needed to manually position the smaller image in the center of the larger one. Regardless, problem solved.

Post Reply

Who is online

Users browsing this forum: Exabot [Bot]