Game Development Reference
Figure 9-5. SoundOn attribute
Open the Speaker actor in the Actor Editor. Create a new rule and name it
''Touch is pressed.'' The condition is ''Action receives event'' ''touch'' is
''pressed.'' Next, drag and drop a Change Attribute behavior and change
game.SoundOn to (game.SoundOn+1)%2 as per Figure 9-6.
Figure 9-6. Touch is pressed rule
Now, create a new rule and name it ''SoundOn is equal to 1.'' The condition will
be ''Attribute''''game.SoundOn''''=''''1''. Next, drag and drop a Change Image
behavior and set the image to speaker. Lastly, drag and drop a Change Attribute
behavior and change Device.Audio.Sound Volume to 1 as per Figure 9-7.