More issues with rotating/cropping in a Screen - setting a variable resets it (?!)

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
PasswordIsntHunter2
Newbie
Posts: 19
Joined: Sun Jan 07, 2018 6:23 pm
Contact:

More issues with rotating/cropping in a Screen - setting a variable resets it (?!)

#1 Post by PasswordIsntHunter2 »

This is a test script.rpy that demonstrates the problem (should run fine in a new project):

Code: Select all

transform turn(angle):
    rotate angle

transform crop():
    crop (0, 0, 200, 300)

screen foo(angle):
    default hovered = False
    add At("gui/window_icon.png", turn(angle), crop)

    textbutton "Button":
        action Return(0)
        hovered SetScreenVariable("hovered", True)

label start:
    scene bg room
    call screen foo(180)
    "!"
    return
The screen "foo" shows an image at a given rotation, and a button which will dismiss the screen (As always, this is pared down from a much larger project). The button sets a variable in the screen, but it doesn't seem to matter whether the variable even exists or if I use SetVariable() instead.

When I mouse over the button, the image suddenly un-rotates, and is shown as if it only has the crop() transform applied. This happens if the button has SetVariable() or SetScreenVariable() as a hover action (admittedly I didn't test all the actions... but things like Play() seem to be fine).

This also only happens if the turn() transform takes a parameter ("angle"). If it's a rotation by some literal number such as "rotate 180", and the parameter is removed from the transform's definition, it'll be fine. But for my use case I kinda need the parameter.

Is this a screen prediction thing? How do I get around this?

It seems to work fine if I use a variable defined in python, as a statement or in an init block:

Code: Select all

transform turn():
    rotate angle

transform crop():
    crop (0, 0, 200, 300)

screen foo():
    default hovered = False
    add At("gui/window_icon.png", turn, crop)

    textbutton "Button":
        action Return(0)
        hovered SetScreenVariable("hovered", True)

label start:
    scene bg room
    $ angle = 180
    call screen foo
    "!"
    return
This is... OK for my use case so I'll probably go ahead and do this, but it's two statements instead of one, and I was hoping to just be able to pass the variable in. Why does the other example not work?

Post Reply

Who is online

Users browsing this forum: Google [Bot]