Insert Music in game !

venon_itvenon_it Member, PRO Posts: 594
Hi Staff,
i'm an italian People, sorry for my English,

I am creating my first game, I wanted to know some information, to insert a Background music.

1) add music throughout the game, from the first scene to last scene.

2) Alternatively, add music to each scene

and all possibility with the ability to play/stop the music button

Thanks to all Venon

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hi venon_it, Welcome to GameSalad.
    There is a behavior called 'Play Music'. http://gamesalad.com/wiki/behaviors_reference:play_music

    It accepts .aac and .m4a audio files to be used as background music.

    Only one background music can play at one time. It continues throughout scene changes and can be paused with the 'Pause Music' behavior, resumed with the 'Play Music' behavior set to 'resume current music', stopped with the 'Stop Music' behavior, and replaced with a different music file with the 'Play Music' behavior.
  • venon_itvenon_it Member, PRO Posts: 594
    ok perfect, but if i want to create one button (in menu screen) and associate the play and pause/stop how do I do?
    now i create one button and insert "RULE" ---> "actor recieve event" ---->> mouse button-->> " down "

    and insert "PLAY MUSIC" ( with music )

    but when start the game, i push the button MUSIC , music start, after a create another button to START a game, and it start second Scene, and after the Music restart!!! it is not good..the music starts twice!

    Help Me pleaseee
  • johnccjohncc Member Posts: 25
    I too am interested in playing / pausing music with the touch of one button. However, I am new to GameSalad and don't quite understand the instructions tshirtbooth. I appreciate you help if you could guide me a little more on what you mean by game.attribute.

    Thanks!
  • GameSaladGameSalad Key Master, Member Posts: 33
    Hey johncc,

    This may help you along in understanding attributes:
    http://gamesalad.com/wiki/how_tos:gsc_create_attribute\

    This one for buttons:
    http://gamesalad.com/wiki/how_tos:gsc_create_a_button

    And this one for the expression editor:
    http://gamesalad.com/wiki/interface_reference:expression_editor
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hey johncc,

    This may help you along in understanding attributes:
    http://gamesalad.com/wiki/how_tos:gsc_create_attribute\

    This one for buttons:
    http://gamesalad.com/wiki/how_tos:gsc_create_a_button

    And this one for the expression editor:
    http://gamesalad.com/wiki/interface_reference:expression_editor
  • venon_itvenon_it Member, PRO Posts: 594
    i'm sorry...but i don't have more experience...
    i want for first insert a music with a button in menu, but want to have a possibility to stop/pause in every scene or have a possibility to insert a different button/music for every scene.

    For second want to create one button SOUND, i push down the button and start a small sound...

    Now i create and add a new actor, insert a image, crate a "RULE" ---> "actor recieve event" ---->> mouse button-->> " down "
    and insert "PLAY SOUND" ( with sound.ogg ) with flag "Run to completition"

    But if i push the button on every section of screen the sound "start" !!! it is not good! because i want to insert more button with a different sound...and if i click in every section of screen "start all sound" !!!!

    help Me thanksss
  • johnccjohncc Member Posts: 25
    Thank you! I got it! You are great!
  • venon_itvenon_it Member, PRO Posts: 594
    I followed you as you indicated, but the button does not play sound/music !!
    I am attaching the link with a screen.

    thanks

    http://img121.imageshack.us/i/gamesaladmusic01.jpg/

    ( i create a "game" attribute called music (integer set to 0) and "game" called "attribute " for insert "game.attribute" in a rule
  • venon_itvenon_it Member, PRO Posts: 594
    sorry but I did not understand what you're asking me ...

    Help
  • venon_itvenon_it Member, PRO Posts: 594
    okkk,
    Now understand, i try in all mode, and don't function...for me the problem is in the first step, i don't have " Attribute Called : attribute " and when i typing " Attribute: game.attribute " i have an a problem....after i create a attribute denominate " attribute" for insert " game.attribute "
    and don't have a problem, but don't function...
    you see my screen? is all ok?

    Thanksssss
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    In your Play and Stop rules, instead of the "Actor receives event", change it to "Attribute" from the drop down menu. Then from the attribute browser, select your game.Attribute attribute.
    Have it check if that attribute is 0 or 1 (depending if it is play or stop) and just have the Music behaviors there. You don't need the Change Attribute behaviors in those rules.

    Also for your first rule, you may want to look for Touch Pressed instead of Mouse Button Down.
  • venon_itvenon_it Member, PRO Posts: 594
    perfect, we're almost there! now the music Start in automatic-mode and clicking on it will stop, now if I want non automatic start mode? and if i want to restart it ?

    ( i try to insert a pause function.. but don't function... )

    Thankssss

    you can see my setup : http://img132.imageshack.us/i/games01.jpg/

    i try to change first rule (Mouse Button Down) in Touch Pressed but result is the same

    Thankksss for help mee
  • venon_itvenon_it Member, PRO Posts: 594
    in the image with i have Add see a double play, but the image is wrong. in GS insert one Play Rule
Sign In or Register to comment.