Play sound effects with delay
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.
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.
Play sound effects with delay
Hello! I want to play some of sound effects in my game with delay. So I want next phrase to begin appear on say screen and after couple of seconds from that moment sound effect should play. Is there any way to do that? I'd appreciate any help with that.
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Play sound effects with delay
Short of just queuing up silence, no.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
- Donmai
- Eileen-Class Veteran
- Posts: 1960
- Joined: Sun Jun 10, 2012 1:45 am
- Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
- Projects: Slumberland
- Location: Brazil
- Contact:
Re: Play sound effects with delay
You can also choose where in the sentence the sound will play, by using the no wait tag and the extend character. Of course this will only have some effect if cps is not zero.
Code: Select all
"Eileen tried to say something more, but {nw}"
play sound "punch.ogg"
extend "Lucy knocked her down before she could do it."
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)
TOIRE NO HANAKO (A Story About Fear)
Re: Play sound effects with delay
PyTom, Donmai, thank you for your answers!
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Play sound effects with delay
Akakyouryuu made a code to run functions with delay
You can play sound like
$delay_run(1.0, [renpy.curry(renpy.music.play)("filename","sound"), renpy.restart_interaction])
Code: Select all
# http://akakyouryuu.com/配布物/renpy/
# 遅延実行のスクリプトです。
# show expression delay_run(3, [renpy.curry(camera_move)(0, 0, 1000, 0, 3), renpy.restart_interaction])
# show expression delay_run(3, hogehoge_function)
#
# delay_run(delay, functions)
# delay: 遅延する秒数です。
# functions: 遅延実行する関数または関数のリストです。引数を使用したい場合は
# renpy.curry関数を使用してください。
class DelayRunBehavior(renpy.display.layout.Null):
def __init__(self, delay, functions, *args, **properties):
super(DelayRunBehavior, self).__init__(**properties)
self.delay = delay
if not isinstance(functions, list):
functions = [functions]
self.functions = functions
self.args = args
def event(self, ev, x, y, st):
if st >= self.delay:
if renpy.game.interface.drawn_since(st - self.delay):
for function in self.functions:
function()
self.functions = []
delay_run = renpy.ui.Wrapper(DelayRunBehavior)
$delay_run(1.0, [renpy.curry(renpy.music.play)("filename","sound"), renpy.restart_interaction])
Who is online
Users browsing this forum: Donmai