Incremental Attribute and Play Sound

j0nmarkj0nmark Member Posts: 10
Hey all. I have not posted here since Gamesalad first came out and there were two people in the forums, but I just recently started experimenting with some ideas again. Of course I didn't make it too far before I was stumped. I think what I'm trying to accomplish is fairly simply though so I'm hoping somebody has a quick and easy answer.

What I want to do is have an actor where every time it is touched it will play a similar but slightly different sound... and it will cycle through maybe 6 of these sounds. I created a Game Attribute called rr (for round robin) and I have an actor (which is currently just called square1). For the 'square1' actor I have a rule that has two conditions:

1) Attribute (game.rr) = 1
2) Actor receives event 'touch' is 'pressed'

If those conditions are met I have 'Play Sound' (playing 'test1.ogg') followed by 'Change Attribute' - (game.rr) To: 2

And then I just have 5 more similar rules for when (game.rr) = 2 or 3, etc. all the way to 6... and on the rule where (game.rr) = 6 at the end I change it back to 1... so that it should keep going through the same cycle as you touch the actor.

When I test the game, it must not be changing the game.rr attribute because it just keeps playing the same sound over and over again. I feel like there is just some basic concept I'm missing here. Please help!

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    I would set it up like this:

    In the square1 Actor,
    Make one Rule that contains six other rules plus a change attribute, like this:

    Rule
    ALL
    When TOUCH is pressed
    When TOUCH is INSIDE

    Rule
    When game.rr = 1
    Play Sound test1.ogg
    Rule
    When game.rr = 2
    Play Sound test2.ogg
    Rule
    When game.rr = 3
    Play Sound test3.ogg
    Rule
    When game.rr = 4
    Play Sound test4.ogg
    Rule
    When game.rr = 5
    Play Sound test5.ogg
    Rule
    When game.rr = 6
    Play Sound test6.ogg

    Change Attribute
    game.rr To: (game.rr+1)%6
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Is the inside needed? I've never used it. What does it do that is different from just touch pressed?
  • j0nmarkj0nmark Member Posts: 10
    Awesome! Thanks so much for your help. This worked great, although I did end up having to change the starting number to 0 and go to 5 otherwise there would be one mouse click (or touch) that didn't do anything.
Sign In or Register to comment.