LayeredImage with relative positions inside a screen renders wrong positions

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
qirien
Miko-Class Veteran
Posts: 504
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Contact:

LayeredImage with relative positions inside a screen renders wrong positions

#1 Post by qirien » Mon Dec 02, 2019 3:56 pm

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!
Finished games:
Image
Image
Image
In progress: Our Personal Space 2: Space to Grow

User avatar
PyTom
Ren'Py Creator
Posts: 15454
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

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

#2 Post by PyTom » Mon Dec 09, 2019 11:32 pm

I'm tracking this as bug 2701

https://github.com/renpy/renpy/issues/2071
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
qirien
Miko-Class Veteran
Posts: 504
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Contact:

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

#3 Post by qirien » Tue Dec 10, 2019 9:03 am

OK, thank you!
Finished games:
Image
Image
Image
In progress: Our Personal Space 2: Space to Grow

Post Reply

Who is online

Users browsing this forum: No registered users