• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'py image button and animation code help.

TrippyDippity

New Member
Aug 27, 2023
5
242
Hello, been lurking for a little while on here and I've run into a little snag developing something (in Ren'Py) and I would be very appreciative of assistance. I'm an extremely novice coder and this is the fist issue I haven't been able to solve with brute force trial and error/googling. Please let me know if it is possible at all and if so, where to start.

I have a scene with multiple elements, displaying some animations, "player stat" variables and showing other static graphics. Part of that scene's UI is a "camera zone" that is playing a spicy animation. I've placed an image button with the same dimensions on top of that animation that is essentially a "connect to camera?" button, which, when you click it, removes itself and the animation (previously hidden by the button) shows. So far so good, the effect is somewhat decent.
To make it a little more immersive, I've created a longer "connecting to camera" animation that I would like to loop once when the user clicks the "connect to camera?" button.

So essentially the effect I'm going for is: screen shows with "connect to camera" button hiding animation ---> player clicks button ---> button removes itself and plays "connecting to camera" animation once ---> final animation plays (looping), all on the same scene.

some of the relevant code elements provided below:


Code:
image talking = Movie(play="images/animations/talking.webm", mask="images/animations/talking_mask.webm", Framedrop=False)
image camcoverani1 = Movie(play="images/animations/camcoverani.webm", mask="images/animations/camcoverani_mask.webm", Framedrop=False)

screen camcover:
    imagebutton:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
        auto "buttons/camcover_%s.png"
        action Hide("camcover", transition=None) #play camcoverani1?
        
label mtracker:
    show talking:
    xanchor 0.5
    yanchor 0.5
    xpos 0.5
    ypos 0.5
   #bunch of other variables/graphics displayed here too
Thanks a lot!
 

hiro_san

Newbie
Jul 22, 2023
44
59
Renpy has 'jump' and 'call ', I think use 'jump' when you don't want to go back to that point, and use call when you want to go back.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,202
14,938
So essentially the effect I'm going for is: screen shows with "connect to camera" button hiding animation ---> player clicks button ---> button removes itself and plays "connecting to camera" animation once ---> final animation plays (looping), all on the same scene.

Among the many way, this should do it:

Python:
image talking = Movie(play="images/animations/talking.webm", mask="images/animations/talking_mask.webm", Framedrop=False)
# change here
image camcoverani1 = Movie(play="images/animations/camcoverani.webm", mask="images/animations/camcoverani_mask.webm", Framedrop=False, loop=False )

screen camcover:
    imagebutton:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
        auto "buttons/camcover_%s.png"
        # change here
        action [ Hide("camcover"), Jump( "mtracker" ) ]

label mtracker:
    # add this
    show camcoverani1:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
    pause 1.0  # Assuming that the animation duration is 1.0

    show talking:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
 

TrippyDippity

New Member
Aug 27, 2023
5
242
Among the many way, this should do it:

Python:
image talking = Movie(play="images/animations/talking.webm", mask="images/animations/talking_mask.webm", Framedrop=False)
# change here
image camcoverani1 = Movie(play="images/animations/camcoverani.webm", mask="images/animations/camcoverani_mask.webm", Framedrop=False, loop=False )

screen camcover:
    imagebutton:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
        auto "buttons/camcover_%s.png"
        # change here
        action [ Hide("camcover"), Jump( "mtracker" ) ]

label mtracker:
    # add this
    show camcoverani1:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
    pause 1.0  # Assuming that the animation duration is 1.0

    show talking:
        xanchor 0.5
        yanchor 0.5
        xpos 0.5
        ypos 0.5
Hi there, I really appreciate your swift response. I should have mentioned that label mtracker is also calling the screen camcover image button to block the animation, so when you jump to mtracker, you're recalling the button onto the screen again so it never disappears if you use the solution you provided.
I ended up creating a duplicate screen for the button to jump to, which increases the work flow a bit but it seems like there isn't another solution.
The pause code was super helpful, and it's looking the way I want for the player now. thanks!
 

TrippyDippity

New Member
Aug 27, 2023
5
242
Renpy has 'jump' and 'call ', I think use 'jump' when you don't want to go back to that point, and use call when you want to go back.
Hi! yes, I think the issue is that the jump causes the button that just deleted itself to be shown again, which defeats the purpose. At least that's my best guess at what's happening. I ended up going for duplicate screens so I can just omit showing the "cam blocker" on the second screen.