[Solved] How to add button sounds?
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.
-
- Regular
- Posts: 129
- Joined: Wed Dec 22, 2010 4:12 pm
- Completed: Double Romance
- Projects: Rolland's Candy Shop. Mitzi's Fable
- Tumblr: shwippie
- Deviantart: shwippie
- Contact:
[Solved] How to add button sounds?
How do I add button sounds to the main menu and preference screens in the new version of Ren'Py (6.99.11)? I'd like to do both a hover sound and a select sound. Is it possible to do both?
Last edited by shwippie on Fri Sep 30, 2016 9:02 pm, edited 2 times in total.
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: How to add button sounds?
You can try something like:
Or some variation therein (maybe using textbutton or imagebutton; they mostly take the same style argument).
Code: Select all
screen main_menu():
button:
text "Button w/ Sound" size 48 outlines [(3, "#000000", 0, 0)]
align 0.5,0.75
action NullAction()
background "#0009"
xysize 300, 75
activate_sound "click.ogg" #sound when pressed
hovered Play ("some_track_name", "hover.ogg") #sound when hovered
at slowdis(0.5)
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: How to add button sounds?
There is also hover_sound style property.
By default main menu buttons are hidden in 'navigation' screen.
You can add 'hover_sound' and 'activate_sound' style properties to style 'navigation_button' defined below that screen.
By default main menu buttons are hidden in 'navigation' screen.
You can add 'hover_sound' and 'activate_sound' style properties to style 'navigation_button' defined below that screen.
< < insert Rick Cook quote here > >
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: How to add button sounds?
That's the one; I couldn't remember the name. The new button should look something like this:There is also hover_sound style property.
Code: Select all
screen main_menu():
button:
text "Button w/ Sound" size 48 outlines [(3, "#000000", 0, 0)]
align 0.5,0.75
action NullAction()
background "#0009"
xysize 300, 75
activate_sound "click.ogg" #sound when pressed
hover_sound "hover.ogg" #sound when hovered
Code: Select all
screen navigation():
vbox:
style_prefix "navigation"
xpos gui.navigation_xpos
yalign 0.5
spacing gui.navigation_spacing
if main_menu:
textbutton _("Start") action Start()
else:
textbutton _("History") action ShowMenu("history")
textbutton _("Save") action ShowMenu("save")
textbutton _("Load") action ShowMenu("load")
textbutton _("Preferences") action ShowMenu("preferences")
if _in_replay:
textbutton _("End Replay") action EndReplay(confirm=True)
elif not main_menu:
textbutton _("Main Menu") action MainMenu()
textbutton _("About") action ShowMenu("about")
if renpy.variant("pc"):
## Help isn't necessary or relevant to mobile devices.
textbutton _("Help") action ShowMenu("help")
## The quit button is banned on iOS and unnecessary on Android.
textbutton _("Quit") action Quit(confirm=not main_menu)
style navigation_button is gui_button
style navigation_button_text is gui_button_text
style navigation_button:
size_group "navigation"
properties gui.button_properties("navigation_button")
style navigation_button_text:
properties gui.button_text_properties("navigation_button")
-
- Regular
- Posts: 129
- Joined: Wed Dec 22, 2010 4:12 pm
- Completed: Double Romance
- Projects: Rolland's Candy Shop. Mitzi's Fable
- Tumblr: shwippie
- Deviantart: shwippie
- Contact:
Re: How to add button sounds?
Ocelot wrote: You can add 'hover_sound' and 'activate_sound' style properties to style 'navigation_button' defined below that screen.
Thank you. This worked- there is a point on the screen that makes a sound. It's invisible, though. Should I be able to see it, since a color was defined for it?r_sami wrote: The new button should look something like this:
- papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
- Contact:
Re: How to add button sounds?
Yes, it should show (I gave it a semi-transparent black colour). It's most likely underneath the other menu images and such. You could either put it at the end of the navigation (code is read sequentially), or put it in the screen main_menu().there is a point on the screen that makes a sound. It's invisible, though. Should I be able to see it, since a color was defined for it?
-
- Regular
- Posts: 129
- Joined: Wed Dec 22, 2010 4:12 pm
- Completed: Double Romance
- Projects: Rolland's Candy Shop. Mitzi's Fable
- Tumblr: shwippie
- Deviantart: shwippie
- Contact:
Re: How to add button sounds?
I see it now. Thanks again!r_sami wrote: You could either put it at the end of the navigation (code is read sequentially), or put it in the screen main_menu().
- Treladon
- Regular
- Posts: 40
- Joined: Sat Dec 31, 2016 3:20 pm
- Projects: ToMaG, Feinted Game
- Organization: Kuehler-Corrada Productions
- Deviantart: Journie
- Contact:
Re: [Solved] How to add button sounds?
I know this has been solved already, but, as an added note, to add a sound to one of the pre-made main menu buttons (like the start button) on the new gui version, go to screens:
screen navigation():
vbox:
style_prefix "navigation"
xpos gui.navigation_xpos
yalign 0.5
spacing gui.navigation_spacing
if main_menu:
textbutton _("Start") action Start():
activate_sound "button fx.wav"
Put a colon on the end of a line with 'action' and add " activate_sound "button fx.wav" ".
screen navigation():
vbox:
style_prefix "navigation"
xpos gui.navigation_xpos
yalign 0.5
spacing gui.navigation_spacing
if main_menu:
textbutton _("Start") action Start():
activate_sound "button fx.wav"
Put a colon on the end of a line with 'action' and add " activate_sound "button fx.wav" ".
Who is online
Users browsing this forum: Bing [Bot]