creating a volume control not working
pjnolen
Member Posts: 152
I created a simple volume control. Similar to the tutorial on creating a health bar.
You press the button labeled 'low', and it will lower the bar.
Press the button labeled 'high' and it will raise the bar.
This is pretty much exactly what the tutorial on creating a health bar is. Only, instead of lowering the bar because an actor got 'hit' by another actor, it's just being 'pressed' by the user.
I've gone over the tutorial 20 times, word by word, step by step, and I can't figure out why it's not working. The bar is not getting smaller when I press the lower volume button, just nothing happens. Here's what I setup, can you guys spot my mistake please?
I created an attribute called 'sound volume' as an index, and gave it an attribute of 10.
I created a bar with 30 width and 100 hight. and called it 'sound screen volume' bar.
On that actor I 'constrained attribute' self.size.height to game.voices volumex10
I created a button labeled 'lower volume' with the following rule.
Actor receives event- touch- is pressed
change attribute game.voices volume to game.voices volume-1
The bar will start at 100 height, but not change when you press the 'lower volume' button when it should drop to 90, 80, 70, etc.
You press the button labeled 'low', and it will lower the bar.
Press the button labeled 'high' and it will raise the bar.
This is pretty much exactly what the tutorial on creating a health bar is. Only, instead of lowering the bar because an actor got 'hit' by another actor, it's just being 'pressed' by the user.
I've gone over the tutorial 20 times, word by word, step by step, and I can't figure out why it's not working. The bar is not getting smaller when I press the lower volume button, just nothing happens. Here's what I setup, can you guys spot my mistake please?
I created an attribute called 'sound volume' as an index, and gave it an attribute of 10.
I created a bar with 30 width and 100 hight. and called it 'sound screen volume' bar.
On that actor I 'constrained attribute' self.size.height to game.voices volumex10
I created a button labeled 'lower volume' with the following rule.
Actor receives event- touch- is pressed
change attribute game.voices volume to game.voices volume-1
The bar will start at 100 height, but not change when you press the 'lower volume' button when it should drop to 90, 80, 70, etc.
Comments
http://gamesalad.com/game/1758
Figured it out. I was using the 'x' in the equation for multiply, instead of the '*' symbol.
I knew it was something stupid.
Thanks for the link FMG, I'm checking it out now.
Game.Notches - The number of transitions between 0 and 1 that you want... so, 10 would be 10 spaces, including no volume and full volume.
On touch action -
Game.Audio.Music Volume = Game.Audio.Music Volume-(1/Game.Notches)
(That's the minus button, just change - to + for the plus button)
You can also set it up to fire every .2 seconds or something that you have the button held down, so you don't have to keep tapping it.
Then for the visual indication -
self.Volume = Game.Audio.Music Volume (initialize the local variable at the top)
self.MinVolume = # (The X screen coordinate you want to represent 0 volume, 300 for example)
self.Span = # (The amount of space you want your entire volume bar to cover. For example, 100 would span the volume bar from 300 to 400 in X on the screen)
When self.Volume DOESN'T EQUAL game.Audio.Music Volume
self.Volume = Game.Audio.Music Volume
self.Position.X = self.MinVolume + ( ( self.Span / Game.Notches ) * (self.Volume * Game.Notches ) )
self.Position.Y = (whatever your Y coordinate is, 100 or something)
That pretty much does it.