How do I add a music room to my game's menu?

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.
Message
Author
JapanManiaz
Newbie
Posts: 7
Joined: Fri Sep 06, 2013 8:57 pm
Contact:

Re: How do I add a music room to my game's menu?

#16 Post by JapanManiaz »

WildRose18 wrote:And unfortunately, I now have a new issue T_T is there a way to place more than one column of tracks in the music room? Because mine kinda runs off the page at this rate...
If you still have a problem with that (which seems unlikely) and don't mind a really messy coding, here's what I do:

Code: Select all

# Music Gallery
#
init python:
    # Step 1. Create a MusicRoom instance.
    mr = MusicRoom(fadeout=1.0)    
    # Step 2. Add music files.
    mr.add("Track1.ogg")
    mr.add("Track2.ogg")
    mr.add("Track3.ogg")
    mr.add("Track4.ogg")
    
screen music_room:
    tag menu
    use navigation
    frame background None :
            ypos 10
            xpos 10
            $ ui.grid(cols=2, rows=2, padding=2, transpose=True)    #Change Column and Row number as needed. The numbers of tracks must match the available grid opening or an 'Exception: Grid not completely full' error will come up. The easiest way to solve this is to make up some empty buttons to fill in the spaces.

        # The buttons that play each track.
            textbutton "Track 1" action mr.Play("Track1.ogg")
            textbutton "Track 2" action mr.Play("Track2.ogg")
            textbutton "Track 3" action mr.Play("Track3.ogg")
            textbutton "Track 4" action mr.Play("Track4.ogg")

#Adjust the position of the previous/next/stop buttons
    frame:
        xpos 270
        ypos 410
        has hbox:
            xalign 0.5
            yalign 0.5
       
        # Buttons that let us advance tracks with a bonus stop button.
        textbutton "|<<" action mr.Previous()
        textbutton "X" action mr.Stop()
        textbutton ">>|" action mr.Next()
It took me some fiddling to come up with this (I prefer having more than one page, but I don't know how to do that). This was really messed up, but I'll be happy if it could help somebody.
Attachments
What the code above yield
What the code above yield
What it looks like in my game
What it looks like in my game

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: How do I add a music room to my game's menu?

#17 Post by Tayruu »

I don't know if I'm misunderstanding the function, but I found that ToggleSingleTrack() wouldn't also toggle the button it was attached to. It was always selected. ToggleLoop() meanwhile did that just fine.

To get around this, I ended up doing this instead. (Note that the selected state = single_track being *false*.)

Code: Select all

action If(music_test.single_track, music_test.SetSingleTrack(False), music_test.SetSingleTrack(True))

andyadams
Newbie
Posts: 2
Joined: Mon Feb 09, 2015 4:02 am
Tumblr: andyadams
Deviantart: andyadams
Github: andyadams
Skype: andyadams
Soundcloud: andyadams
Contact:

Re: How do I add a music room to my game's menu?

#18 Post by andyadams »

Not sure if this would be the correct placement of this thread, but seen the question asked before in here.I am new to this.I am a fan of barcode game of visual basic .net.Now i want to have music in my game.How do I get sound/music into my game? Is there a menu or editor within AGS that I can use to add music/sound files into, or what?Any suggestion will be appreciated. Thanks in advance.

User avatar
Magpie
Newbie
Posts: 1
Joined: Wed Feb 24, 2016 1:55 pm
Projects: Untitled dating sim VN
Contact:

Re: How do I add a music room to my game's menu?

#19 Post by Magpie »

The music room works perfectly fine and I'm thankful for the code.

Just one question: how could I make it so that when you select a song it changes the background image of the music room?

Post Reply

Who is online

Users browsing this forum: No registered users