animated imagebuttons - rapid animation on change state - help

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
Kaldonis
Newbie
Posts: 15
Joined: Tue Dec 12, 2017 6:37 pm
Contact:

animated imagebuttons - rapid animation on change state - help

#1 Post by Kaldonis »

Hi All,

I was wondering if anyone has come across this problem before. I have an animated image button in my game and although I can get it to display fine, when you hover over it or unhover the animation plays rapidly once and then settles back down into its normal animation cycle. This will happen every time it changes state.

I've included the code for the image (which is its own separate tab, not under the image button code). I've tried making the button with Auto, made another image up with raina_button_hover, which is the same animation as I want the button to constantly be animated even when it is hovered.

I've removed the custom mouse cursor from the code and its made no difference the animation always plays one fast loop when the mouse either hovers or unhovers over the button. I've tried to have a static image for when the button is hovered but again same thing happens.
The image never hangs on an animation frame or anything like that.

I can't think what's left to try at this point.

Code: Select all

screen mckitchen_room:
    
    if morning == True:
        add "bg mckitchen day"
    else:
        add "bg mckitchen night"
    
        imagebutton idle "raina_button_idle" focus_mask True action Jump("raina_talk") mouse "hover"

init -3:
    image raina_button_idle:
        "buttons/anim/kraina.png"
        linear 0.1
        "buttons/anim/kraina2.png"
        linear 0.1
        "buttons/anim/kraina3.png"
        linear 0.1
        "buttons/anim/kraina4.png"
        linear 0.1
        "buttons/anim/kraina5.png"
        linear 0.1
        "buttons/anim/kraina6.png"
        linear 0.1
        "buttons/anim/kraina7.png"
        linear 0.1
        "buttons/anim/kraina8.png"
        linear 0.1
        "buttons/anim/kraina9.png"
        linear 1
        "buttons/anim/kraina8.png"
        linear 0.1
        "buttons/anim/kraina7.png"
        linear 0.1
        "buttons/anim/kraina6.png"
        linear 0.1
        "buttons/anim/kraina5.png"
        linear 0.1
        "buttons/anim/kraina4.png"
        linear 0.1
        "buttons/anim/kraina3.png"
        linear 0.1
        "buttons/anim/kraina2.png"
        choice:
            4.5
        choice:
            3.5
        choice:
            1.5
        repeat
        
Any help or pointing me in a direction will be greatly appreciated.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: animated imagebuttons - rapid animation on change state - help

#2 Post by Imperf3kt »

"linear" used that way is incorrect. Essentially, you're telling renpy "do nothing and take 0. 1 seconds to do it"

From what I can tell, you need a pause instead.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Kaldonis
Newbie
Posts: 15
Joined: Tue Dec 12, 2017 6:37 pm
Contact:

Re: animated imagebuttons - rapid animation on change state - help

#3 Post by Kaldonis »

Hey thanks for the fast response, put pause in there and the animation plays the same. Still runs fast when changing states. I was never sure on the difference between pause and linear.

I've uploaded a gif of the problem if it helps.
Attachments
Animated button problem
Animated button problem

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: animated imagebuttons - rapid animation on change state - help

#4 Post by Imperf3kt »

Did you add a pause statement to the choice options as well?

Code: Select all

screen mckitchen_room:
    
    if morning == True:
        add "bg mckitchen day"
    else:
        add "bg mckitchen night"
    
        imagebutton idle "raina_button_idle" focus_mask True action Jump("raina_talk") 

init -3:
    image raina_button_idle:
        "buttons/anim/kraina.png"
        pause 0.1
        "buttons/anim/kraina2.png"
        pause 0.1
        "buttons/anim/kraina3.png"
        pause 0.1
        "buttons/anim/kraina4.png"
        pause 0.1
        "buttons/anim/kraina5.png"
        pause 0.1
        "buttons/anim/kraina6.png"
        pause 0.1
        "buttons/anim/kraina7.png"
        pause 0.1
        "buttons/anim/kraina8.png"
        pause 0.1
        "buttons/anim/kraina9.png"
        pause 1
        "buttons/anim/kraina8.png"
        pause 0.1
        "buttons/anim/kraina7.png"
        pause 0.1
        "buttons/anim/kraina6.png"
        pause 0.1
        "buttons/anim/kraina5.png"
        pause 0.1
        "buttons/anim/kraina4.png"
        pause 0.1
        "buttons/anim/kraina3.png"
        pause 0.1
        "buttons/anim/kraina2.png"
        choice:
            pause 4.5
        choice:
            pause 3.5
        choice:
            pause 1.5
        repeat
        
Your imagebutton has no hover state. I do not know what the mouse hover bit was for.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Kaldonis
Newbie
Posts: 15
Joined: Tue Dec 12, 2017 6:37 pm
Contact:

Re: animated imagebuttons - rapid animation on change state - help

#5 Post by Kaldonis »

Hi ya, I put the pauses in the choice options and still the same result i'm afraid. The mouse hover bit just turns the mouse cursor blue, it works that why for any image buttons so the players know they've found something to click on. I've already taken that part out just in case that was the problem but again it didn't fix the problem.
I also put code in there for a hover, but again not changed a thing, it rapidly completes the animation cycle before continuing with the hovered state.

Code: Select all

 imagebutton idle "raina_button_idle" hover "raina_button_idle" focus_mask True action Jump("raina_talk")
I appreciate you taking a look at this, I can't work out what I'm doing wrong.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: animated imagebuttons - rapid animation on change state - help

#6 Post by Imperf3kt »

Hopefully somebody else steps forth to help as my computer is currently broken (possibly irreparably)for the next few days, at least, I won't have access to renpy to test this myself and without trying it out, I can not see why it won't behave.

I have other computers I can use, but none are currently in a state to install renpy.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Kaldonis
Newbie
Posts: 15
Joined: Tue Dec 12, 2017 6:37 pm
Contact:

Re: animated imagebuttons - rapid animation on change state - help

#7 Post by Kaldonis »

Thanks for looking in to this, I've done a work around which is to Add the animated image to the screen and then put a see through image button over it. It's not the solution I hoped for but for now in these early builds of the game it'll do.

Post Reply

Who is online

Users browsing this forum: No registered users