Animation reseting when changing condition

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
MelonSandia
Newbie
Posts: 2
Joined: Sat Jan 13, 2024 12:34 pm
Contact:

Animation reseting when changing condition

#1 Post by MelonSandia »

Hii, so I have an imagebutton and I want that only if the condition canClick is True and you click the button, the action gets executed. I made the following code and it's working fine. The problem is that everytime "canClick" changes from True to False or viceversa, the animation image "animation1" gets restarted to the first frame. I really don't know how to solve this issue and I haven't found a solution online. Thanks for reading, and it's also my first time posting here

Code: Select all

default canClick = False
##This is the animation I'm using as an image for the imagebutton
image animation1:
    "images/Tuto/1.png"
    pause 1.0
    "images/Tuto/2.png"
    pause 1.0
    "images/Tuto/3.png"
    pause 1.0
    "images/Tuto/4.png"
    pause 1.0
    repeat

##This is the screen and imagebutton  code
screen TUTORIAL1:
    imagebutton:
        at dissolve_with_atl2(0.2)
        idle "animation1"
        focus_mask True
        if canClick == True:
            action [Hide("TUTORIAL1"),Jump("TUTO1")]

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1042
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Animation reseting when changing condition

#2 Post by m_from_space »

Put the "animation" keyword inside your transform.

Code: Select all

image animation1:
    animation
    "images/Tuto/1.png"
    pause 1.0
    ...

MelonSandia
Newbie
Posts: 2
Joined: Sat Jan 13, 2024 12:34 pm
Contact:

Re: Animation reseting when changing condition

#3 Post by MelonSandia »

m_from_space wrote: Sat Jan 13, 2024 4:42 pm Put the "animation" keyword inside your transform.

Code: Select all

image animation1:
    animation
    "images/Tuto/1.png"
    pause 1.0
    ...
omg, It works perfectly. I'm so dumb. Thanks a lot

Post Reply

Who is online

Users browsing this forum: mold.FF, Semrush [Bot]