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.
-
ReAnimator
- Regular
- Posts: 64
- Joined: Mon Dec 16, 2013 1:00 pm
-
Contact:
#1
Post
by ReAnimator » Tue Aug 16, 2022 4:29 am
Hello.
I want this blinking animation to have fadein and out effect.
Currently trans.alpha is set to 1.0 and 0.0 respectively so it shows and hides instantly.
Is there any way to achieve this?
Code: Select all
init python:
def show_op(trans, st, at):
if st < 1 / x:
trans.alpha = 1.0
return 0
else:
return None
def hide_op(trans, st, at):
if st < 1 / x:
trans.alpha = 0.0
return 0
else:
return None
screen blinking():
add Solid("#ffff"):
at transform:
function show_op
function hide_op
repeat
timer 1.0 action SetVariable("x", x + 1) repeat True
label start:
$ x = 1
show screen blinking
"I want to add fadein and out effect to trans.alpha."
return
-
ReAnimator
- Regular
- Posts: 64
- Joined: Mon Dec 16, 2013 1:00 pm
-
Contact:
#3
Post
by ReAnimator » Tue Aug 16, 2022 11:48 am
Yeah,
To be exact I want it to look like attached video.
Can it be done with on show statement?
I really can't figure it out.
-
Attachments
-
- Comp.zip
- (9.88 KiB) Downloaded 2 times
-
Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#4
Post
by Ocelot » Tue Aug 16, 2022 1:26 pm
You can make a custom warper (
https://www.renpy.org/doc/html/atl.html ... -statement ) and use it in transform:
Code: Select all
init python:
def Blink(repetitions):
def blink(t):
from math import pi, cos
t = t * t * (pi * 2 * repetitions - pi)
w = cos(t)
return (w + 1) / 2 # [-1, 1] → [0, 1]
return blink
define blink = Blink(20)
transform induce_seizure:
alpha 1.0
warp blink 10 alpha 0.0
screen blinking():
add Solid("#ffff") at induce_seizure
label start:
show screen blinking
"I want to add fadein and out effect to trans.alpha."
return
< < insert Rick Cook quote here > >
-
ReAnimator
- Regular
- Posts: 64
- Joined: Mon Dec 16, 2013 1:00 pm
-
Contact:
#5
Post
by ReAnimator » Tue Aug 16, 2022 1:46 pm
Brilliant!
You know what, there's no way I can figure this out on my own. How can you do that, man... this makes me really sad... still no idea about that math code... lol
Thanks for your help. This is exactly I want.
-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#6
Post
by m_from_space » Wed Aug 17, 2022 7:57 am
Ocelot wrote: ↑Tue Aug 16, 2022 1:26 pm
transform induce_seizure:

Thanks for the laugh.
Users browsing this forum: Bing [Bot]