How to turn off sound when the Renpy game is deactivated.

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
yoyuchi
Regular
Posts: 58
Joined: Sat Jul 09, 2022 1:39 pm
Contact:

How to turn off sound when the Renpy game is deactivated.

#1 Post by yoyuchi » Mon Aug 08, 2022 2:57 am

Hi everyone, When Renpy game window is deactivated by clicking on another window during the game,
I want to turn off all sounds of the game.

Code: Select all

                        imagebutton:
                            idle "grp/deactivate_ON_idle.png"
                            hover "grp/deactivate_ON_hover.png"
                            selected_idle "grp/deactivate_ON_selected.png"
                            selected_hover "grp/deactivate_ON_hover2.png"
                            pos (13, 373)                          
                            action
                         
                        imagebutton:
                            idle "grp/deactivate_OFF_idle.png"
                            hover "grp/deactivate_OFF_hover.png"
                            selected_idle "grp/deactivate_OFF_selected.png"
                            selected_hover "grp/deactivate_OFF_hover2.png"
                            pos (14, 373)                            
                            action 
            
I'd like to add a menu to the preference, how should I write the command?
Thank you for any advice.

User avatar
enaielei
Regular
Posts: 114
Joined: Fri Sep 17, 2021 2:09 am
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: How to turn off sound when the Renpy game is deactivated.

#2 Post by enaielei » Mon Aug 08, 2022 3:16 am

I don't think there's an easy way to do this other than having access to the window object itself to access its state/properties.
This documentation might help you.

Post Reply

Who is online

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