Playing a song before the title screen, and a different one during it.

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
meiri_
Newbie
Posts: 6
Joined: Sun Aug 09, 2020 11:03 am
Completed: Apple Pie, MyGF, Morishun Part 1
Projects: Morishun Part 2
Tumblr: aozoratomarry
itch: meiri
Location: Brazil
Discord: crossexamineaparrot#3631
Contact:

Playing a song before the title screen, and a different one during it.

#1 Post by meiri_ » Sun Aug 09, 2020 1:05 pm

So, I'm going through an issue with the main menu music. Usually I'd just uncomment the music line on options.rpy and call it a day, but this game I'm working on needs something different.

Basically, I have a screen thats called before the main menu itself ("fakestart"), which is supposed to play a happy song. Then, after the player clicks on the screen, a screen crack effect plays, and the music is supposed to change into a darker one.

Here's my opening.rpy.

Code: Select all

label splashscreen():
    scene black
    $ renpy.pause(2.5, hard=True)

    # greet, add more voice lines later
    $ hour=time.strftime("%H",time.gmtime())
    $ hour=int(hour)
    if hour >8 and hour <22:
        play sound "audio/voice/welcome home.mp3"
    else:
        play sound "audio/voice/komi hey.mp3"

    #back to logo
    show logo at transform_logo
    $ renpy.pause(5, hard=True)

    hide logo
    $ renpy.pause(2, hard=True)
    ##### This is where I'd like the happy song to start playing! ######################
    #play music "audio/bgm/fake title.mp3"

    return

## Press to Start Screen


screen fakestart():
    tag menu
    if not persistent.ch5:
        add "images/cg/initial menu.png"

    #if persistent.ch6:
        #add "backgroundch5.png"
    #if persistent.ch7:
        #add "backgroundch7.png"
    #if persistent.ch8:
        #add "backgroundch8.png"
    #if persistent.ch9:
        #add "initial menu.png"


    add "images/overlays/start.png" xalign 0.5 yalign 0.5 at transform_blink

    ##### I want the player to click the screen, stop the happy music, and play the creepy one.
    ### "audio/bgm/title screen.mp3"
    ##### But I can't make it work :(
    button:
        xysize (config.screen_width, config.screen_height)
        activate_sound "audio/se/crash.ogg"
        action Show("main_menu", transition=shatter)

label before_main_menu():
    call screen fakestart
    $ renpy.pause(1.5, hard=True)
I cannot, for the life of me, figure out a way for this work. The happy music still plays over the darker music even if i tell the game to stop all the songs (I believe because of how the options.rpy thing is set up?), or it won't play at all, or it plays and then is stopped by the other music.

I've tried messing with stuff like audio channels to turn off the happy music, but that just reverts the problem - darker plays while happy doesn't at all. I've also tried different variations of the opening code, placing the music play part in different locations in the code... still nothing.


Can someone help me out? This is driving me insane! lol

User avatar
RicharDann
Veteran
Posts: 284
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Playing a song before the title screen, and a different one during it.

#2 Post by RicharDann » Mon Aug 10, 2020 9:02 am

I'm gonna guess you're using the config.main_menu_music variable in options.rpy
Try commenting out that option if that's what you're using, and play the dark song from the button in fakestart:

Code: Select all

button:
    xysize (config.screen_width, config.screen_height)
    activate_sound "audio/se/crash.ogg"
    action [Play("music", "audio/bgm/title screen.mp3"), Show("main_menu")] #play the real title screen from here
Or, in your main_menu screen, add an on 'show' action:

Code: Select all

screen main_menu:
    on 'show':
        action Play("music", "audio/bgm/title screen.mp3")
This should basically have the same effect at the same time stopping the previously playing song (if both are on the same channel).
The most important step is always the next one.

User avatar
meiri_
Newbie
Posts: 6
Joined: Sun Aug 09, 2020 11:03 am
Completed: Apple Pie, MyGF, Morishun Part 1
Projects: Morishun Part 2
Tumblr: aozoratomarry
itch: meiri
Location: Brazil
Discord: crossexamineaparrot#3631
Contact:

Re: Playing a song before the title screen, and a different one during it.

#3 Post by meiri_ » Mon Aug 10, 2020 11:32 am

RicharDann wrote:
Mon Aug 10, 2020 9:02 am
I'm gonna guess you're using the config.main_menu_music variable in options.rpy
Try commenting out that option if that's what you're using, and play the dark song from the button in fakestart:

Code: Select all

button:
    xysize (config.screen_width, config.screen_height)
    activate_sound "audio/se/crash.ogg"
    action [Play("music", "audio/bgm/title screen.mp3"), Show("main_menu")] #play the real title screen from here
    
:shock: It worked! I can't believe it was that simple. Thank you so much!!

Post Reply

Who is online

Users browsing this forum: No registered users