another background music issue, please help

pjnolenpjnolen Member Posts: 152
I have music begin playing when the 'start screen' comes up. I have buttons for sound options, difficulty settings, etc.

When the screen comes up, the music starts playing fine. If the player goes to the sound options, difficulty screen, etc, it keeps playing fine.

But if the player clicks the back button to return to the main start screen, the music resets back to the beginning. I need it to just keep playing. If they go to one screen, then back, then another screen, then back, it just keeps resetting back to the beginning of the music until they press start and go into the game.

How do I just have it continue playing and not interrupt itself continuously until they start the game. Changing the setting for looping it, doesn't affect it.

I even created a boolean attribute, and when the screen loads it sets it to true, and when that is set to true start playing the music. I hoped, if it was already set to true it wouldn't reset the music. It still does.

So...

I created a button, that when pressed changed the boolean to true. So that it would not reset, and just stay true. But that didn't work either, every time the scene loads, it resets the music.

Is there a way to have the music not reset when the main screen loads?

Comments

  • ThejackaspenThejackaspen Member Posts: 27
    I have this exact same problem, I've tried adding timers and different attributes but whenever I go back to the main menu scene, where the music actor is set, It always restarts.

    I was about to start a new thread but saw this one so I thought I could bump yours up if you still had that problem.
  • quantumsheepquantumsheep Member Posts: 8,188
    Have a scene before your main scene - let's say a 'splash' screen, where you display your logo.

    Have a rule in your logo actor:

    If you press your logo, or after a certain amount of time, go to the main scene.

    *before* The 'go to next scene' behaviour, put in your 'play music' behaviour.

    Because you'll never go back to the splash screen (you seem to be going back to the menu screen at most) the music should never stop playing or restart.

    Hope that helps,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
  • ThejackaspenThejackaspen Member Posts: 27
    Thanks man! I can't believe it was that simple :P I should have been able to figure that out, but with doing that and tweaking some things it works!
  • quantumsheepquantumsheep Member Posts: 8,188
    Glad I could help.

    Sometimes it helps to think 'outside the box' a bit.

    Fortunately, I live outside the box! :D

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • beefy_clyrobeefy_clyro Member Posts: 5,394
    quantumsheep said:
    Have a scene before your main scene - let's say a 'splash' screen, where you display your logo.

    Have a rule in your logo actor:

    If you press your logo, or after a certain amount of time, go to the main scene.

    *before* The 'go to next scene' behaviour, put in your 'play music' behaviour.

    Because you'll never go back to the splash screen (you seem to be going back to the menu screen at most) the music should never stop playing or restart.

    Hope that helps,

    QS :D

    This works until you iniate a reset scene behaviour, my game requires a reset scene and when this happened the music never continues, dont know how to get around it!
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    beefy, you should avoid the reset scene method if possible, i think that will slowly increase memory usage over time, it's not a perfect method.
  • gazjmgazjm Member Posts: 578
    The best way I found is to have an attribute called music playing.

    Have a rule which says :

    If musicplaying = 0
    Play music
    Change musicplaying to 1

    This will play the music only if music isn't already playing.
    Then In your gameoverscreen have a rule to change musicplaying back to 0, to start music again once you return to the menu!
  • quantumsheepquantumsheep Member Posts: 8,188
    jonmulcahy said:
    beefy, you should avoid the reset scene method if possible, i think that will slowly increase memory usage over time, it's not a perfect method.

    Absolutely agree - in almost two years of using GS I've not put 'Reset Scene' into any of my games.

    I think that we were asking GS to reset everything with one button click essentially. Unfortunately, not all variables were included in the reset, so I just did it the manual way.

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.