Imperf3kt wrote: ↑Fri Jan 11, 2019 4:30 pm
Okay, I found some time to check what the code should be.
This is what I use in one project:
Code: Select all
on "show" action Play("music", song)
Music tells renpy to use the music channel, which is what the main menu music plays on, so it'll stop it and play the new song without you needing to do much.
The "song" bit is the file to play. It requires this additional bit of code before the start label:
I also suggest, to start the main menu music playing again when a player returns to the main menu, it may be necessary to add one of these to the main menu as well. If you do, config.main_menu_music won't be used.
If you still need a bit of help understanding what I've posted here, just say and I'll jump on my laptop and put it together for you.
Ok, I managed to make it work but it was funny.
So first, I try your code in the game menu screen:
Code: Select all
if renpy.get_screen("preferences"):
on "show" action Play("music", song)
And I defined the "song" in script.rpy. And it works, but only for the ingame game menu. I mean, if I choose the preferences from the main menu, it doesn't change anything. But if I launch a game, and during the game, right click to have the preferences menu, then I can hear the song...
But what you've showed me was exactly what I needed for my gallery page
To have this to work in the main menu, I simply add the action... after the action in main_menu.
To be clear, I change this:
Code: Select all
hotspot (1338, 408, 568, 73) action ShowMenu("gallery")
to this:
Code: Select all
hotspot (1338, 408, 568, 73) action [ShowMenu("gallery"), Play("music", song)]
And it works perfectly !
of course, as you said, I had to add the same action to "return", so in gallery.rpy:
Code: Select all
.... action [Return(), Play("music", song2)].....
And of course define song2 as the main_menu music.
I don't know if I was clear, sorry for my bad English.
And thank you very much Imperf3kt, you help me a lot!
Now, I can keep going with this game