[SOLVED] Imagebutton action to show an animation and run a function consecutively

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
Wiceramond
Regular
Posts: 25
Joined: Mon Dec 07, 2020 8:40 am
Contact:

[SOLVED] Imagebutton action to show an animation and run a function consecutively

#1 Post by Wiceramond »

Hi!

I want to make an on screen loading animation when I click an imagebutton. How do I use the "action" part to do that? I want loading animation to be shown on screen (can be bunch of images too, doesn't matter as long as it's working) then do the Function() parts I provided.

I can show an animation and do the Function but the problem is that I need imagebutton action to run the Function after the animation is done, but they all work at the same time.

Thanks in advance!
Last edited by Wiceramond on Mon Mar 06, 2023 12:22 pm, edited 1 time in total.

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: Imagebutton action to show an animation and run a function consecutively

#2 Post by enaielei »

Code: Select all

screen animation(img, time, *actions):
    # automatically hides the screen on timer end, if not then just use `action actions`
    timer time action (list(actions) + [Hide("animation")])
    add img
Then in your action...

Code: Select all

# assuming the animation lasts for 12 seconds and the animation was defined using the `image` statement
action Show("animation", None, "your defined animation", 12, Function(...))

User avatar
Wiceramond
Regular
Posts: 25
Joined: Mon Dec 07, 2020 8:40 am
Contact:

Re: Imagebutton action to show an animation and run a function consecutively

#3 Post by Wiceramond »

enaielei wrote: Mon Mar 06, 2023 10:34 am

Code: Select all

screen animation(img, time, *actions):
    # automatically hides the screen on timer end, if not then just use `action actions`
    timer time action (list(actions) + [Hide("animation")])
    add img
Then in your action...

Code: Select all

# assuming the animation lasts for 12 seconds and the animation was defined using the `image` statement
action Show("animation", None, "your defined animation", 12, Function(...))
Thank you so much, it works like a charm!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], MagicBuns