[Solved] Animated Toggle Buttons Not Animating

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
Thee Forsaken One
Regular
Posts: 191
Joined: Sun Mar 01, 2009 8:10 pm
Completed: RE: Alistair++; Backstage Pass; Three Guys That Paint; The Reject Demon Toko - Ch 0; The Menagerie
Projects: Dizzy Hearts; The Stargazers Remastered
Organization: Forsaken Productions
Tumblr: ForsakenProductions
Deviantart: TheeForsakenOne
Location: Scotland
Contact:

[Solved] Animated Toggle Buttons Not Animating

#1 Post by Thee Forsaken One » Wed Feb 12, 2020 2:18 pm

I usually prefer searching through the forums rather than creating a new topic but couldn't really find particularly useful information (either not relevant or very out-of-date).

I've got some toggles that when clicked are supposed to play a small animation where the button slides from one position to another (It's based a lot on the toggle switches commonly found on a mobile interface). The issue is that animation only ever plays once on a reload and never again. When clicked the button immediately jumps to the last frame of the animation.

This is the code for setting up the animations:

init:
image toggleLeft:
"gui/toggle/toggle5.png"
pause 0.125
"gui/toggle/toggle4.png"
pause 0.125
"gui/toggle/toggle3.png"
pause 0.125
"gui/toggle/toggle2.png"
pause 0.125
"gui/toggle/toggle1.png"
pause 0.125
"gui/toggle/togglel.png"

image toggleRight:
"gui/toggle/toggle1.png"
pause 0.125
"gui/toggle/toggle2.png"
pause 0.125
"gui/toggle/toggle3.png"
pause 0.125
"gui/toggle/toggle4.png"
pause 0.125
"gui/toggle/toggle5.png"
pause 0.125
"gui/toggle/toggler.png"


This is the button in question:

imagebutton idle "toggleLeft" selected_idle "toggleRight" hover "toggleLeft" selected_hover "toggleRight" action Preference("auto-forward", "toggle")

The animation does work if I add a repeat command to the end but naturally that ends up looking a bit silly and it's not what I'm looking for. I just want the animation to play once but evidently Ren'Py takes that as only once ever and never allows it to be repeated again. I suspect I've either made a mistake in setting up the animation or imagebutton is not the appropriate type of button to use. Unfortunately, not sure where to proceed from here. I've tried different variations but have not met with success so far.

I'd really welcome any suggestions to resolve the issue.
Last edited by Thee Forsaken One on Thu Feb 13, 2020 2:37 pm, edited 1 time in total.
Image

User avatar
gas
Miko-Class Veteran
Posts: 601
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Animated Toggle Buttons Not Animating

#2 Post by gas » Wed Feb 12, 2020 10:59 pm

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Thee Forsaken One
Regular
Posts: 191
Joined: Sun Mar 01, 2009 8:10 pm
Completed: RE: Alistair++; Backstage Pass; Three Guys That Paint; The Reject Demon Toko - Ch 0; The Menagerie
Projects: Dizzy Hearts; The Stargazers Remastered
Organization: Forsaken Productions
Tumblr: ForsakenProductions
Deviantart: TheeForsakenOne
Location: Scotland
Contact:

Re: Animated Toggle Buttons Not Animating

#3 Post by Thee Forsaken One » Thu Feb 13, 2020 2:37 pm

gas wrote:
Wed Feb 12, 2020 10:59 pm
viewtopic.php?t=41616#p437220
Thanks. That's gotten me pretty close to what I was looking for.
Image

Post Reply

Who is online

Users browsing this forum: Gabiszon, Google [Bot], Nero, trooper6