Need help with small Soundboard project

MarcoColMarcoCol Member, PRO Posts: 279
edited May 2012 in Working with GS (Mac)
Hi,
I am new here and have now a few days a look on GameSalad and tried my first project.
I create a Soundboard with 12 buttons. I set a rule for each button to play a soundfile when touching the button and change the button so that the user see, that this sound will be player currently.
So the soundboard doesn't work correctly. The change of the image does work with all buttons fine. But play the music of the soundfile does only work for the last button!
Also while I add each button, also only the last has worked. Did you have an idea?

My Rule:
if touched pressed (for the button), play music / change image.
If touched outside (for the button), stop music / change image.

Answers

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    your rules are conflicting with each other.

    the outside from all the other buttons kills the music when you touch the button you want to play

    You will likely have to add a stop music button or do something like putting your stop music and change images into the otherwise section of the touch is pressed rule.
  • MarcoColMarcoCol Member, PRO Posts: 279
    Thank you tendrmer,

    I tried to put the stop music and chance image into the "Otherwise"section, but then nothing happes. In my try, the button changed again into the outgoing image - as it should be. But only there is no sound, than that from the latest button is be played.
    I didn't want to make a stop music button.
    Any other ideas?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    You need to watch more videos and read the cookbook it takes time to learn GS.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You could get a little more complex and instead of the buttonhaving play music rules the button just simply changes an Game level integer attribute to a specific Value


    so each button would look like this

    When touch is pressed
    --Change game.musicnumber to 1

    When game.musicnumber = 1
    --Change image to button down
    Otherwise
    --change image to button up

    You will need that for each button with a unique value for the button

    Then in the scene have a controller actor or you could even just put this in the background actor

    When game.musicnumber = 1
    --Stop Music
    --Timer after 0.1 sec
    ---PlayMusic
    Otherwise
    --When game.musicnumer = 2
    ----Stop Music
    ----Timer after 0.1 sec
    -----PlayMusic
    Otherwise
    Etc…….
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Also, make sure you have permission from the owner of the audio if you are going to publish it, as it's illegal to publish an app without permission.

    Ace
  • MarcoColMarcoCol Member, PRO Posts: 279
    @mynameisace: thank you for the information. I have all rights (sounds and artworks)
    @tenrdrmer: It do it, but without the "Stop Music" and "Time after..." and it worked good.
    So the board is almost complete, but I want it, that a click on the current played sound (where the button is marked) the sound stops to play and also the button change into the startbutton.
    I tried several ways (for example to have a new attribute =2, when touching again) but it doesn't work.
    I didn't know how and where to handle it, that this current touched button can touched again. I've tried it with "pressed" or "inside", but both is no correct.

    Also I've worked with the tutorial and the cookbook and now much more is clear. But with this question my theory isn't working :(
  • simo103simo103 Member, PRO Posts: 1,331
    @MarcoCol ... jumping into this a little late so I'm not sure this helps mush but have you seen this thread for a button as a switch?:
    http://forums.gamesalad.com/discussion/678/help-making-a-toggle-switch
  • MarcoColMarcoCol Member, PRO Posts: 279
    Hmmm. thank you. I think I have just the same, but I want to hit the button again. Currently, the sound will be played from start. But it should be, that the button will be reset and the music will be stopped.
    In my mind came a few seconds ago: Set all attributes at start on 0. Then when touched is pressed set attribute to 1 and when touched ist outside set attribute to 2.
    Then if button is 0 = stop sound, change into standard-image
    Then if button is 1 = play sound, change image
    Then if button is 2 = stop sound, change image
    Could this work? I'll try...

  • MarcoColMarcoCol Member, PRO Posts: 279
    I'll try it as my suggestion, but it doesn't work.
    Which method should I use for hitting again the button?
    "Inside" doesn't work :(
  • jckmcgrawjckmcgraw Member Posts: 647
    @marcocol

    Could you upload your project file? There have been many solutions given to you.

    Regards,
    Jack McGraw
  • MarcoColMarcoCol Member, PRO Posts: 279
    What file should I upload?
    Or should I promt the two main files?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @MarcoCol Compress your GameSalad project file into a .zip file and then post a link to your file (e.g. from DropBox, MediaFire, etc.).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MarcoColMarcoCol Member, PRO Posts: 279
    Sorry, can't upload something. But it is easy to post my code:
    Button 1 (image = 1) has the code:
    ----
    Rule
    All
    Actor receives event => touch is pressed
    Change Attribute "game.sound1" to "1"
    -
    Rule
    All
    Actor receives event => touch is outside
    Change Attribute "game.sound1" to "0"
    -
    Rule
    All
    Attribute "game.sound1" = "1"
    Change Image to "1a"
    -
    Rule
    All
    Attribute "game.sound1" = 0
    Change Image to "1"
    ----
    Button 2 (image = 2) has almost the same code:
    ----
    Rule
    All
    Actor receives event => touch is pressed
    Change Attribute "game.sound2" to "1"
    ...
    ====
    An invisible Actor in the board has the code:
    ----
    Rule
    All
    Attribute "game.sound1" = 1
    Play Music "1"
    Otherwise
    Rule
    All
    Attribute "game.sound2" = 1
    Play Music "2"
    ...
    ----

    I've tried several things, but I didn't know how to check if the button was pressed again. If I hit another button, everything works fine (current Music stops, new button will be changed and new Music will be player). But if hit the same, then the music starts new, but it should stop and the button should be as unpressed.

    BEst
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2012
    But your rule says that when the button is pressed, play music. So why are you expecting it to stop when you press it again?

    As was mentioned above, if you want to toggle a button (on/off), you can see http://forums.gamesalad.com/discussion/678/help-making-a-toggle-switch.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MarcoColMarcoCol Member, PRO Posts: 279
    Well, it works for 90% now. I've done it with the link, with a toggling button. But there is just one small problem left:
    If touch first button, everything works. If touch again, music stops, button changed. This works with all buttons. Good. But if don't touch the current playing button again and hit another one, then sometimes no new sound was played, but the button changing is correct. But also sometimes it works.
    I've tried also to set the attribute to 0 if the button was touched outside, without success.
Sign In or Register to comment.