I'm trying to implement a system like Life Is Strange where when the choice menu screen comes up, the currently playing music/sfx will fade to a lower volume and decision making background music will play on top.
I know how to do this in the script itself each time, but was hoping there's a better way to edit the screen itself so it happens automatically each time.
Playing music in the choice/menu screen
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.
- HideAndSeekVN
- Newbie
- Posts: 2
- Joined: Tue Apr 06, 2021 12:31 pm
- Contact:
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Playing music in the choice/menu screen
First of all, I would register channel on which choice music would play:
Then, I would modify existing choice screen, so it silences main music channel and play choice music when it shown. Then reverts everything back when it is hidden:
You can read more on used function and action in documentation:
https://www.renpy.org/doc/html/screen_a ... io-actions
https://www.renpy.org/doc/html/audio.html#functions
I have attached example project, so you could test it and see, how it is done.
Code: Select all
init python:
renpy.music.register_channel("choice_music", mixer="music", loop=True)
Code: Select all
screen choice(items):
style_prefix "choice"
vbox:
for i in items:
textbutton i.caption action i.action
on "show" action [Play(channel="choice_music", file="audio/choice.mp3", fadein=1.0), Function(renpy.music.set_volume, 0.2, delay=1.0, channel="music")]
on "replace" action [Play(channel="choice_music", file="audio/choice.mp3", fadein=1.0), Function(renpy.music.set_volume, 0.2, delay=1.0, channel="music")]
on "hide" action [Stop(channel="choice_music", fadeout=1.0), Function(renpy.music.set_volume, 1.0, delay=1.0, channel="music")]
on "replaced" action [Stop(channel="choice_music", fadeout=1.0), Function(renpy.music.set_volume, 1.0, delay=1.0, channel="music")]
https://www.renpy.org/doc/html/screen_a ... io-actions
https://www.renpy.org/doc/html/audio.html#functions
I have attached example project, so you could test it and see, how it is done.
- Attachments
-
- TEST61908.zip
- (6.45 MiB) Downloaded 14 times
< < insert Rick Cook quote here > >
- HideAndSeekVN
- Newbie
- Posts: 2
- Joined: Tue Apr 06, 2021 12:31 pm
- Contact:
Re: Playing music in the choice/menu screen
Ahh, I think this is perfect! I added additional functions to silence the sound channel as well and it seems to work great. Thanks a bunch!!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]