Main Menu with a Video Background Code

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Geckos
Veteran
Posts: 471
Joined: Fri Aug 17, 2012 8:33 am
Completed: Brilliant Shadows, Perceptions of the Dead, The Phantom Icecream Truck
Projects: Embers of Magic, Pale Spectrum, Perceptions of the Dead
Organization: Ithaqua Labs
Tumblr: geckosart
Deviantart: sitaart
Contact:

Main Menu with a Video Background Code

#1 Post by Geckos »

Just posting a quick guide to using a movie (such as webm) for your main menu, as I spent a bit of time today trying to work out all of the kinks! (I was missing one line of code.)

The code uses a webm video in the background with imagebuttons over it. This is the result! (in a few animated frames for easy showing.)
potd2_menu_anim2.gif

Code: Select all


screen main_menu():

    # This ensures that any other menu screen is replaced.
    tag menu

    add Movie(size=(1920, 1080))
    on "show" action Play("movie", "movies/potd2_menu.webm", loop=True)
    on "hide" action Stop("movie")
    on "replace" action Play("movie", "movies/potd2_menu.webm", loop=True)
    on "replaced" action Stop("movie")


    imagebutton auto "ui/play_%s.png" xpos 870 ypos 800 focus_mask None action Start()
    imagebutton auto "ui/load_%s.png" xpos 1180 ypos 850 focus_mask None action ShowMenu('load') 
    imagebutton auto "ui/options_%s.png" xpos 500 ypos 830 focus_mask None action ShowMenu('preferences') 
    imagebutton auto "ui/credits_%s.png" xpos 150 ypos 800 focus_mask None action ShowMenu('extras')
    imagebutton auto "ui/quit_%s.png" xpos 1600 ypos 820 focus_mask None action Quit() 
    
   

Image ImageImage

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Main Menu with a Video Background Code

#2 Post by mitoky »

Thank you very much! This is very helpful. If you dont mind me asking, what exactly does 'on replace' and 'on replaced' do? I assume they do the same as show and hide judging by the code, only with the diffrence that thats what happens if the mian menu isnt called/shown by a commend but by return etc?

User avatar
Geckos
Veteran
Posts: 471
Joined: Fri Aug 17, 2012 8:33 am
Completed: Brilliant Shadows, Perceptions of the Dead, The Phantom Icecream Truck
Projects: Embers of Magic, Pale Spectrum, Perceptions of the Dead
Organization: Ithaqua Labs
Tumblr: geckosart
Deviantart: sitaart
Contact:

Re: Main Menu with a Video Background Code

#3 Post by Geckos »

mitoky wrote: Sat Dec 23, 2017 7:10 pm Thank you very much! This is very helpful. If you dont mind me asking, what exactly does 'on replace' and 'on replaced' do? I assume they do the same as show and hide judging by the code, only with the diffrence that thats what happens if the mian menu isnt called/shown by a commend but by return etc?
Those are actually what tripped me up for awhile, which is why I thought a little example of the code might help others, too. As far as I can tell, 'on replace' means when the menu replaces a screen (such as, you're coming back from the preferences), and 'on replaced' means when the menu is replaced by something, like when you go into preferences.
Image ImageImage

User avatar
Geckos
Veteran
Posts: 471
Joined: Fri Aug 17, 2012 8:33 am
Completed: Brilliant Shadows, Perceptions of the Dead, The Phantom Icecream Truck
Projects: Embers of Magic, Pale Spectrum, Perceptions of the Dead
Organization: Ithaqua Labs
Tumblr: geckosart
Deviantart: sitaart
Contact:

Re: Main Menu with a Video Background Code

#4 Post by Geckos »

Geckos wrote: Sun Dec 24, 2017 1:54 am
mitoky wrote: Sat Dec 23, 2017 7:10 pm Thank you very much! This is very helpful. If you dont mind me asking, what exactly does 'on replace' and 'on replaced' do? I assume they do the same as show and hide judging by the code, only with the diffrence that thats what happens if the mian menu isnt called/shown by a commend but by return etc?
Those are actually what tripped me up for awhile, which is why I thought a little example of the code might help others, too. As far as I can tell, 'on replace' means when the menu replaces a screen (such as, you're coming back from the preferences), and 'on replaced' means when the menu is replaced by something, like when you go into preferences.

I was missing one of the replace/d tags and the video kept disappearing when I went into preferences and back out via return.
Image ImageImage

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Main Menu with a Video Background Code

#5 Post by wyverngem »

A very clean code thanks for sharing.

Post Reply

Who is online

Users browsing this forum: No registered users