[SOLVED] Keep Movie Playing When Switching Menus?

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
lking22
Regular
Posts: 50
Joined: Sun Dec 03, 2017 3:33 am
Projects: Grey Feather
itch: freefall-games
Contact:

[SOLVED] Keep Movie Playing When Switching Menus?

#1 Post by lking22 »

Sorry if this is a little vague, need to go to work soon so I'm rushing a little. Basically, I have a movie playing in the background of my main menu and want it to continue playing underneath other menu options (ie Load, Help, etc). Right now I've only figured out how to get it to stop and restart when switching from the main menu to other menus. Is there a way to fix that? Heck, I'd even prefer having the movie pause when in other menus and keep playing when switching back to the main menu. I don't like having it restart each time.

Code below, sorry for the large section, I don't have time to split it up right now. A lot of it is default but I have made large changes to the navigation screen to put the options down the bottom, as well as a few changes to the game menu. Haven't made any changes to the Load/Save/About/etc screens yet.

Code: Select all

################################################################################
## Main and Game Menu Screens
################################################################################

## Navigation screen ###########################################################
##
## This screen is included in the main and game menus, and provides navigation
## to other menus, and to start the game.

screen navigation():
    style_prefix "navigation"
    if main_menu:
        imagemap:
            idle "main_menu_idle.png"
            hover "main_menu_hover.png"
            ground "main_menu_ground.png"
            selected_idle "main_menu_hover.png"

            hotspot (570, 930, 131, 150) action Start()
            hotspot (775, 930, 120, 150) action ShowMenu("load")
            hotspot (950, 930, 170, 150) action ShowMenu("preferences")
            hotspot (1165, 930, 135, 150) action ShowMenu("about")
            hotspot (1370, 930, 125, 150) action ShowMenu("help")
            hotspot (1580, 930, 111, 150) action Quit(confirm=not main_menu)
    else:
        imagemap:
            idle "game_menu_idle.png"
            hover "game_menu_hover.png"
            ground "game_menu_ground.png"
            selected_idle "game_menu_hover.png"
            selected_hover "game_menu_hover.png"

            hotspot (480, 940, 130, 145) action MainMenu()
            hotspot (666, 940, 160, 145) action ShowMenu("history")
            hotspot (884, 940, 992, 145) action ShowMenu("save")
            hotspot (1084, 940, 120, 145) action ShowMenu("load")
            hotspot (1256, 940, 178, 145) action ShowMenu("preferences")
            hotspot (1482, 940, 130, 145) action ShowMenu("help")
            hotspot (1682, 940, 127, 145) 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")


## Main Menu screen ############################################################
##
## Used to display the main menu when Ren'Py starts.
##
## https://www.renpy.org/doc/html/screen_special.html#main-menu
screen main_menu():
    ## This ensures that any other menu screen is replaced.
    tag menu
    style_prefix "main_menu"
    add Movie(size=(1920, 1080))
    on "show" action Play("movie", "mm.mpg", loop=-1)
    on "hide" action Stop("movie")
    on "replaced" action Stop("movie")
    on "replace" action Play("movie", "mm.mpg", loop=-1)
    ## This empty frame darkens the main menu.
    frame:
        pass
    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    use navigation
    if gui.show_name:
        vbox:
            text "[config.name!t]":
                style "main_menu_title"
            text "[config.version]":
                style "main_menu_version"

style main_menu_frame is empty
style main_menu_vbox is vbox
style main_menu_text is gui_text
style main_menu_title is main_menu_text
style main_menu_version is main_menu_text

style main_menu_frame:
    xsize 420
    yfill True

    background "gui/overlay/main_menu.png"

style main_menu_vbox:
    xalign 1.0
    xoffset -30
    xmaximum 1200
    yalign 1.0
    yoffset -30

style main_menu_text:
    properties gui.text_properties("main_menu", accent=True)

style main_menu_title:
    properties gui.text_properties("title")

style main_menu_version:
    properties gui.text_properties("version")


## Game Menu screen ############################################################
##
## This lays out the basic common structure of a game menu screen. It's called
## with the screen title, and displays the background, title, and navigation.
##
## The scroll parameter can be None, or one of "viewport" or "vpgrid". When
## this screen is intended to be used with one or more children, which are
## transcluded (placed) inside it.

screen game_menu(title, scroll=None, yinitial=0.0):
    style_prefix "game_menu"
    if main_menu:
        pass
    else:
        add FileCurrentScreenshot() at blur
        add gui.game_menu_background
    frame:
        style "game_menu_outer_frame"
        hbox:
            frame:
                style "game_menu_content_frame"
                if scroll == "viewport":
                    viewport:
                        yinitial yinitial
                        scrollbars "vertical"
                        mousewheel True
                        draggable True
                        pagekeys True
                        side_yfill True
                        vbox:
                            transclude
                elif scroll == "vpgrid":
                    vpgrid:
                        cols 1
                        yinitial yinitial
                        scrollbars "vertical"
                        mousewheel True
                        draggable True
                        pagekeys True
                        side_yfill True
                        transclude
                else:
                    transclude
    use navigation
    imagebutton idle "back_idle.png" hover "back_hover.png" action Return():
        xpos 1790
        ypos 15
    label title
    if main_menu:
        key "game_menu" action ShowMenu("main_menu")

style game_menu_outer_frame is empty
style game_menu_navigation_frame is empty
style game_menu_content_frame is empty
style game_menu_viewport is gui_viewport
style game_menu_side is gui_side
style game_menu_scrollbar is gui_vscrollbar

style game_menu_label is gui_label
style game_menu_label_text is gui_label_text

style return_button is navigation_button
style return_button_text is navigation_button_text

style game_menu_outer_frame:
    bottom_padding 45
    top_padding 180

    background "gui/overlay/game_menu.png"

style game_menu_content_frame:
    left_margin 60
    right_margin 30
    top_margin 0

style game_menu_viewport:
    xsize 1380

style game_menu_vscrollbar:
    unscrollable gui.unscrollable

style game_menu_side:
    spacing 15

style game_menu_label:
    xpos 75
    ysize 180

style game_menu_label_text:
    size gui.title_text_size
    color gui.accent_color
    yalign 0.5

style return_button:
    xpos gui.navigation_xpos
    yalign 1.0
    yoffset -45
Releases:
Image

Current projects:
In the Ashes of Dawn
Split Psyche
Savestate Gambit

User avatar
lking22
Regular
Posts: 50
Joined: Sun Dec 03, 2017 3:33 am
Projects: Grey Feather
itch: freefall-games
Contact:

Re: [SOLVED] Keep Movie Playing When Switching Menus?

#2 Post by lking22 »

After some experimenting, I figured out that removing 'tag menu' from the main menu code fixed the problem. Since the main menu isn't being replaced by the sub-menus, the background keeps playing.
Releases:
Image

Current projects:
In the Ashes of Dawn
Split Psyche
Savestate Gambit

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: [SOLVED] Keep Movie Playing When Switching Menus?

#3 Post by Per K Grok »

lking22 wrote: Mon Jul 08, 2019 1:40 am Sorry if this is a little vague, need to go to work soon so I'm rushing a little. Basically, I have a movie playing in the background of my main menu and want it to continue playing underneath other menu options (ie Load, Help, etc).

----
Try this

define your movie as a displayable

Code: Select all

image Tumble=Movie (play="video/Tumble.ogv")

in screens add a new screen

Code: Select all

screen movieBG():
    add "Tumble"
Under 'screen main_menu():'
after line 'add gui.main_menu_background', add new line
use movieBG

Under 'screen game_menu(title, scroll=None, yinitial=0.0):'
after line 'style "game_menu_outer_frame" ', add new line
use movieBG

and you should have a contentiously playing movie background to all the menu screens

Post Reply

Who is online

Users browsing this forum: Google [Bot]