playMaker

Author Topic: Music over different scenes  (Read 2169 times)

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Music over different scenes
« on: May 23, 2014, 03:52:25 PM »
So I have a music manger on the main menu.  It plays music.  I goto scene 2 to choose a vehicle and to scene 3 to choose a arena.  The music stays as I use don't destroy on load.  Now, if I exit and go back to scene 1 which is the main menu, there is a problem.  It reloads the scene and a 2nd music manger appears in the hiercy playing the music a 2nd time.  So my question is, how can I get it to NOT load the music manger game object when going from scene 2 to scene 1?  This way the original music that loaded at game start will just keep playing.

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Music over different scenes
« Reply #1 on: May 23, 2014, 04:04:47 PM »
I figured this one out.  I set up a bool with music playing or not.  then on scene 2, if I go back to scene 1, I set the global variable to true.  That way scene 1 checks and sees the music is playing so it does noting.

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Music over different scenes
« Reply #2 on: May 23, 2014, 05:25:15 PM »
I also downloaded the destroy tag.  I tagged the music game manager as music.  Then when the game starts (after the menus), I destroy everything with that tag.  The reason is that going to the main menu would create a new game manager.  That way, whenever going to the main menu from the game, there will be only 1 game manager.

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: Music over different scenes
« Reply #3 on: May 23, 2014, 07:13:01 PM »
Alternatively, you could start the music manager in an Init scene- before loading the main menu scene. I do this on android to make the first loading screen a bit shorter with a nearly empty scene, and passing the loading on to future scenes.  ;)

Init scene is one you'd never come back to. Main menu however you might go to a lot.

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Music over different scenes
« Reply #4 on: May 24, 2014, 01:04:38 AM »
Yeah I did think about that too.  A scene 0 which loads the music and then scene 1 is the main menu.  That way the music would never get loaded twice.  Another good idea.