Change sound played after touching actor

DankStewDankStew Member Posts: 36
Hey there fellow Game Salad users, I'll keep it quick and simple because everybody is prob. busy with every/anything iPad: how do you make an actor play a different sound when touched?

Ex. Touch the main actor to play sound 1,
Touch alt actor, then touch main actor to play sound 2

Any help would be greatly appreciated. Thank you.

Comments

  • DankStewDankStew Member Posts: 36
    Any help on this one? Am I blind to the answer? Is it a Boolean rule? I don't know... help please.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    A boolean only allows for two values (true or false). If you only have two sounds a boolean will work fine. If you have more than two you need to use a game integer attribute and set it to 1

    Let's say you have three:

    So in the switch button have a rule that says

    Rule -when touch is pressed
    _ Rule- game.sound=1
    change attribute game.sound to 2

    _ Rule- game.sound=2
    change attribute game.sound to 3

    _ Rule- game.sound=3
    change attribute game.sound to 1

    In main actor
    Rule When touch is pressed
    _ Rule When game.sound=1
    play sound1

    _ Rule When game.sound=2
    play sound2

    _ Rule When game.sound=3
    play sound3
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    the "_ rule" means they are all within the rule that doesn't have the "_" in front of it.
  • VoidedSkyVoidedSky Member Posts: 1,095
    Attribute: game.soundnumber(Interger)
    Main: When actor recieves event, touch/and when attribute game.sound = 1
    Play sound XXXXX
    .........................................
    When actor recieves event, touch/and when attribute game.sound = 2
    Play sound YYYYY

    Alt Actor: When touch is inside/ and when touch is released/and when game.sound = 1
    Change game.sound to 2
    ..........................................
    When touch is inside/ and when touch is released/and when game.sound = 2
    Change game.sound to 1

    This should work
    ~CTM

    EDIT: Wow it took me so long to write this, 3 others posted! sorry!
  • DankStewDankStew Member Posts: 36
    Cool! Thanks for the help guys. I was thinking of just doing a simple one or the other sound choice, but I like the potential with your ways of doing it with the attributes.

    Thanks scitunes and CowTechMan!
Sign In or Register to comment.