Play sound for in-game choice buttons?

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
User avatar
Amie
Regular
Posts: 28
Joined: Tue Jun 06, 2017 4:48 am
Contact:

Play sound for in-game choice buttons?

#1 Post by Amie » Wed Jun 07, 2017 1:45 pm

Hello, I'm new here (and new to Ren'Py), I'm having so much fun with this software, but I got stuck and I'm not sure how to do something. I'd like to be able to play a sound when you select an in-game menu choice, I did find some older discussions about it but I'm still having trouble trying to make it work, is anyone able to walk me through it for the new version of Ren'Py?

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Play sound for in-game choice buttons?

#2 Post by DannyGMaster » Wed Jun 07, 2017 2:47 pm

A way is to modify the choice screen, probably located in your Project's screens.rpy file.

Around line 202, there should be something like this:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action 
In the same line as the textbutton, you can add activate_sound "sound.ogg", it's a button style property, (search Style Properties in the documentation for more on them). It would end up like this:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action activate_sound "select.ogg"
You can also add hover_sound "hover.ogg" if you want that too.

Hope this helps.
The silent voice within one's heart whispers the most profound wisdom.

User avatar
Amie
Regular
Posts: 28
Joined: Tue Jun 06, 2017 4:48 am
Contact:

Re: Play sound for in-game choice buttons?

#3 Post by Amie » Wed Jun 07, 2017 3:02 pm

Thanks so much DannyGMaster! That's perfect, I'll try it out now, thank you! :D

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Play sound for in-game choice buttons?

#4 Post by DannyGMaster » Thu Jun 08, 2017 10:41 am

Glad I helped :-D
The silent voice within one's heart whispers the most profound wisdom.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]