I'm using yellow and grey blocks (active object) to show how high or low is the game volume and using the left and right arrows, you can change this. I'm distributing this in 10 blocks in total, like this:
In this case the global variable (sound_volume) is 60. I made this test to increase or decrease the volume:
The idea of the loop is run N times depending of sound_volume value.
On loop sound_bar_full I create (N loop times) the yellow block object on screen:
sound_volume = 60
sound_bar_full loop times (sound_volume / 10) = 6 (create 6 yellow blocks)
sound_bar_empty loop times (10 - (sound_volume / 10)) = 4 (create 4 grey blocks)
And set position of X:
On loop sound_bar_empty I create (N loop times) the grey object:
And also set the position of X:
So as you can see, when you press “left” key, I destroy all objects using a qualifier and remake the images running both loops, but I have two problems here:
1- When I press the arrows key, the objects created is not only one, it creates a dozen of blocks;
2- When the volume comes to 100, the entire bar disappear (destroyed).
So, that's it.
Thanks for reading.