How to remove an animated element when animation completes?

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
Soul Reaver
Newbie
Posts: 8
Joined: Tue Mar 20, 2012 5:52 am
Contact:

How to remove an animated element when animation completes?

#1 Post by Soul Reaver »

I've created an animated image:

Code: Select all

image c_slash1:
    "images/combat/slash1f1.png"
    pause 0.2
    "images/combat/slash1f2.png"
    pause 0.2
    "images/combat/slash1f3.png"
    pause 0.2
    "images/combat/slash1f4.png"
    pause 0.2
    "images/combat/slash1f5.png"
    pause 0.2
    "images/combat/slash1f6.png"
    pause 0.2
This works just fine when I show it in-game.

However, lets say I use the above animated image in an imagebutton - what could I do to make that imagebutton hide/disappear completely once the animation completes (ie, to make it a 'one-off' animation)?

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

Re: How to remove an animated element when animation completes?

#2 Post by Imperf3kt »

You need to use a transform for that.
Place the on show statement inside a screen and edit accordingly
https://www.renpy.org/doc/html/atl.html?#on-statement
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

Soul Reaver
Newbie
Posts: 8
Joined: Tue Mar 20, 2012 5:52 am
Contact:

Re: How to remove an animated element when animation completes?

#3 Post by Soul Reaver »

Thank you, but I don't understand how 'on' can be used to detect when an animation has finished? Could you please show some sample code that achieves that?

EDIT: As far as I can see, the above would only let me visually hide the image/imagebutton by making it transparent, it wouldn't actually remove the element itself from the screen.

Ideally I'd like to do something sort of like this:

Code: Select all

image c_slash1:
    "images/combat/slash1f1.png"
    pause 0.1
    "images/combat/slash1f2.png"
    pause 0.1
    "images/combat/slash1f3.png"
    pause 0.1
    "images/combat/slash1f4.png"
    pause 0.1
    "images/combat/slash1f5.png"
    pause 0.1
    "images/combat/slash1f6.png"
    pause 0.1
    event animationend

Code: Select all

show c_slash1:
	on animationend hide c_slash1
But obviously that doesn't work because 'event' can only be used inside the ATL block and not detected in the main code.
So I still don't know how to remove the actual c_slash1 element when the animation has ended.

But I'm quite inexperienced so far, so maybe I'm missing something?

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: How to remove an animated element when animation completes?

#4 Post by Kia »

you can use a timer to hide the screen or change a variable after a specific delay
you have 6 pause of 0.1
timer 0.6 action Hide("something")
it's not the perfect solution but it's better than nothing

Soul Reaver
Newbie
Posts: 8
Joined: Tue Mar 20, 2012 5:52 am
Contact:

Re: How to remove an animated element when animation completes?

#5 Post by Soul Reaver »

Ok. I'll design something like built-in countdown for the various buttons/images.

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

Re: How to remove an animated element when animation completes?

#6 Post by Imperf3kt »

Rethinking this, you can use the notify screen as a stock screen and modify as necessary.
I just remembered I did this in a project to display an "achievement unlocked" animation when necessary.
I'll find the code and paste it here soon (TM)
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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Belgerum, Google [Bot]