Continuing same music through multiple layouts

This forum is currently in read-only mode.
  • I have a couple layouts I want to use, but I want to use the same music throughout, without restarting it. So I was wondering if it was possible to continue the music playing through multiple layouts without stopping?

  • Check the "Global" box under the common properties for the XAudio2 object. And if you're not using the XAudio2 object, you definitely should be.

  • Thanks. And yes, I am using the XAudio2 object, since I know of no other =)

    Well, I have another problem now. The music starts at the menu, and at the menu there are several options. The menu layout has this in it's event sheet-

    Start of Layout-
         XAudio2- Play music "asdf.mp3"
         XAudio2- Loop music
    [/code:1xsj263p]
    
    So when I enter a sub-item of the menu, I go to another layout. In that layout, there is a back button- so basically, when I return to the menu, the code runs through again, and thus, the music starts playing from the top. Can I make this not happen, perhaps by putting the play music code elsewhere? Or prevent it from running through twice?
  • Perhaps try something like this:

    First, create a global variable called "playmusic" and set it's default value to 1. Then put this code in the first layout(this is all in one event):

    +Start of Layout
    +Is global variable 'playmusic' equal to 1
         -XAudio2- Play music "asdf.mp3"
         -XAudio2- Loop music
         -Set global variable 'playmusic' to 0
    [/code:3k4mmjin]
    
    The global variable acts like a flag to determine if the music can play or not.  Hope that helps.
  • Thanks for the reply. However, is +Is global variable 'playmusic' equal to 1 a sub-event of Start of Layout? If it is, I can't find it for some reason. I looked under system and could not find a variable thingymagigy. Could you perhaps quickly make a .cap?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You define your global variables in the Application properties. Then you can compare them in a condition with "System->Compare global variable."

  • Added this one to the FAQ because it seems to come up a lot.

  • Thanks to linkman2004 for the code (it works, trying to figure out how it works so I can use it for other purposes =) ) and deadeye for the help on where to find it, and of course to Ashley for the program in the first place. Glad it got added to the FAQ. Thanks all!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)