Page 1 of 1

LayeredImage with relative positions inside a screen renders wrong positions

Posted: Mon Dec 02, 2019 3:56 pm
by qirien
I'm using LayeredImage to put together a family photo that will be shown every year. The people's sprites need to change based on certain conditions, so the photo will be different every year. I know this isn't exactly how LayeredImage was intended to be used, but I thought I'd give it a try because the code is more elegant.

Here's my LayeredImage code:

Code: Select all

    layeredimage family_photo:
        always:
            "pond"
        if (neglectful < 50):
            align(0.3, 1.0)
            "him happy"
        if True:
            align(0.7, 1.0)
            "her normal"
        group kid:        
            align(0.45, 1.0)
            attribute happy:
                "kid happy"
            attribute sad:
                "kid sad"
        if True:
            "polaroid"

    image family_photo_small = LayeredImageProxy("family_photo", Transform(crop=(306,22,675,680), zoom=photo_scale_factor))
The resulting LayeredImage works just fine when I show it with "show"; for example:

Code: Select all

show family_photo_small happy
gives this image:
screenshot0062.png
However, when I try to use the image inside a screen with "add", the positions of the people are offset. This is not what I would expect. Am I doing something wrong, or is this a bug?

Code: Select all

screen test_family_photo_screen():
    frame:
        xfill True
        yfill True
        hbox:
            vbox:
                label "Photo 1"
                add "family_photo_small happy"
            vbox:
                label "Photo 2"
                label "We'll move this down a little."
                add "family_photo_small happy"
            textbutton "Done" action Return()
This screen looks like this:
screenshot0063.png
Edit: I tried using fixed positions instead of relative positions, and it seemed to work fine. However, because the size of the sprites is dynamic as the children grow up, I really need to use relative positions, so I hope there's a way to do it!

Re: LayeredImage with relative positions inside a screen renders wrong positions

Posted: Mon Dec 09, 2019 11:32 pm
by PyTom
I'm tracking this as bug 2701

https://github.com/renpy/renpy/issues/2071

Re: LayeredImage with relative positions inside a screen renders wrong positions

Posted: Tue Dec 10, 2019 9:03 am
by qirien
OK, thank you!