Rule: If music is playing...

DrGlickertDrGlickert Member Posts: 1,135
edited February 2012 in Working with GS (Mac)
I have a game with many levels (which means many scenes). If I start my game and start on level one I have a "Play Music" behavior. If I start my game on level 2, then the music doesn't play because I don't have the behavior.
Now, when you play level 1, then go to level 2, the music continues.
But if I add "Play Music" behaviors to each scene, then the music starts over at each scene.
Is there a way to create a rule that "If music is playing: don't play music" and/or "If music is NOT playing; play music"?

Comments

  • ozboybrianozboybrian PRO Posts: 2,102
    Just set up a Boolean with an otherwise.

    If Boolean/PlayMusic is true. Play song 1.
    Otherwise (if false) play song 2.
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    edited February 2012
    I THINK this is what you need.

    You're going to need an attribute. A boolean like Ozboy said.

    Each scene will have to have the play music behavior in it since you want to be able to start from any level and have music playing. And you will need a rule in each scene that states - If attribute.music is "true" play music. And another rules that says - If attribute.music is "false" play music.

    And in the buttons that change scenes, you will need a rule to change it back and forth from true to false, and on the next level change it from false to true, and so on and so on...
  • ozboybrianozboybrian PRO Posts: 2,102
    See Slick, we do make a good team ;)

    Orrr this might work. Set up an integer.
    Have a number for each level and set up a corresponding rule and number for the song to play with each number as it goes up. (MIGHT work)
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Actually, now that I think about it, having a play music behavior will make it start from the beginning every time too. When you start at level 2, are you coming from another menu?

    You may have to have the music start playing at the start screen/menu where you select the level you want to go to, and leave the play music behavior out of each level but the menu, but still do the rules I mentioned minus the play music behavior.
  • ChobbifaceChobbiface PRO Posts: 491
    edited February 2012
    Just to reiterate, I think this is what you need, which is essentially what SlickZero has said:

    Make a boolean 'Music On' (starts off false)
    In each level place the behaviour: if music on=false: PLAY music; change attribute music on to true
    otherwise rule (i.e. music is true/already playing): RESUME music

    A few scenarios, which I think covers what you want to achieve:
    - Open game: Click on level 1 - music should trigger now as music on was false. Now progress on to level 2, music should resume playing since music on is now true
    - Open game: Let's say you click to start on level 2 first instead - music should trigger exactly as above since music on was false to begin with.
Sign In or Register to comment.