Characters "stuck" anchored to top of screen? [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
lexiconofashes
Newbie
Posts: 6
Joined: Tue Feb 19, 2019 1:40 pm
Contact:

Characters "stuck" anchored to top of screen? [SOLVED]

#1 Post by lexiconofashes »

Hello, I am having a very strange issue where two of my characters' images are floating in only one specific scene, and only when using xalign or custom transforms.

I cannot even begin to imagine what the problem is.

If I use at default, at center, at left, or at right, they appear anchored to the bottom of the screen as usual. If I use xalign or a custom transform (that is only a set xalign value) the top of their sprites appears anchored to the top of the screen.

While messing around with the code, I found I could make them move from a default position (such as default, center, left, right) to a set xalign position and they would be anchored properly. However, I would rather they just appear where they should.

The same sprites work properly in other scenes. Nonetheless, I have double checked and there is no extra transparent space or anything wrong with the sprites. The scene starts only with four characters appearing. Only two characters of the four that appear in the scene are stuck to the top of the screen, but all of them are set with xalign. Is there anything I'm possibly overlooking?

This is the start of the scene right now. (I doubt this code is the problem, but I wouldn't know what else to show):

Code: Select all

    label lunch_with_Kokichi:

    # Kokichi & friends: Kokichi, Gonta, Miu, Kiibo
    scene bg005:
    show kokichi handsmirk:
        xalign .3
    show miu basic:
        xalign .6
    show kiibo basic:
        xalign -.1
    show gonta openmouth:
        xalign 1.5
And this is what it produces:

Image

(Obviously I plan to fix the numbers so that the characters are evenly spaced, but their actual values seem to have no effect on whatever is causing the sprites to do that.)
Last edited by lexiconofashes on Thu Mar 14, 2019 10:50 am, edited 1 time in total.

User avatar
lexiconofashes
Newbie
Posts: 6
Joined: Tue Feb 19, 2019 1:40 pm
Contact:

Re: Characters "stuck" anchored to top of screen?

#2 Post by lexiconofashes »

For now I have changed everyone's locations so that the two floating characters are in the default "right" and "left" positions, and the ones with no problem are in the center, but I would really rather understand what caused this and place them as I originally wanted.

User avatar
lexiconofashes
Newbie
Posts: 6
Joined: Tue Feb 19, 2019 1:40 pm
Contact:

Re: Characters "stuck" anchored to top of screen?

#3 Post by lexiconofashes »

I understand there's probably not enough information here to help, but if anyone can offer guidance on where to look besides the show code, that would be really appreciated.

The same exact character sprites work in other scenes. Showing different sprites of the same character in this scene still has them anchored to the top.

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Characters "stuck" anchored to top of screen?

#4 Post by strayerror »

This happens because when you use a colon and an indented block with the show statement, you're actually dynamically defining an inline transform. This is then used in place of the default transform which is typically defined as Position(align=(0.5, 1.0)) (center, bottom) which is responsible for anchoring spites to the bottom of the window. You have a few options for how to mitigate this:

You can either force the default transform to be applied before your inline transform like so:

Code: Select all

    show kokichi handsmirk at default:
        xalign .3
# or
    show kokichi handsmirk at default, Position(xalign=.3)
Or alternatively, you can add the bottom align to your inline transform:

Code: Select all

    show kokichi handsmirk:
        align (.3, 1.)
# or
    show kokichi handsmirk at Position(align=(.3, 1.))
Finally, if this is something you'll want to do a lot, it may make sense to define a custom transform with the bottom alignment baked in:

Code: Select all

define bottom = renpy.partial(Position, yalign=1.)

label lunch_with_Kokichi:
    show kokichi handsmirk at bottom(xalign=.3)
Hope that helps and makes sense!

User avatar
lexiconofashes
Newbie
Posts: 6
Joined: Tue Feb 19, 2019 1:40 pm
Contact:

Re: Characters "stuck" anchored to top of screen? [SOLVED]

#5 Post by lexiconofashes »

Wow, that was actually quite a simple solution. I had no idea the yalign just had to be redefined when I was specifying the xalign value. But it makes sense- and I feel a bit silly now for having agonized over this for so long, haha!

The fixes you mentioned worked with no issue, so now the characters are placed as originally intended!

Thank you so, so much for the help! I have taken your advice as well and added a few custom transforms for when 4 or 5 characters are present onscreen. You're a lifesaver, really!

Post Reply

Who is online

Users browsing this forum: Google [Bot]