Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Kangourou pas sympa on Fri 19/06/2009 22:35:18

Title: Does a module for a gauge of sound exist ?
Post by: Kangourou pas sympa on Fri 19/06/2009 22:35:18
Hi everybody,
Here juste a simple question,
I would like to know if a module which transform the sliders of the sound to a gauge exist.
In order to do 2 sprite, one full, one empty,
And the full one appears with a mask, a mask which hide a percentage of the sprite.
Thank you, and sorry for my english.
  ;D
Title: Re: Does a module for a gauge of sound exist ?
Post by: on Fri 19/06/2009 23:54:11
A module doesn't exist (yet ;) ), but here's a simple way to fake a gauge.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22559.0 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22559.0)

The principle is simple- you really need only two graphics (as you mentioned), and then you change the width of the button in your code, easy as pie.

(typing "gauge" in the forum search will actually bring up some more topics)
Title: Re: Does a module for a gauge of sound exist ?
Post by: Kangourou pas sympa on Sat 20/06/2009 14:02:04
Thanks,
I don't know anything about code, but I understand what you said.
Just a second question now,
I'll need only two graphics, ok,
But should I make individualy all the button, or it's possible to make them all automaticaly ?
Ina dvance, thank you.
Title: Re: Does a module for a gauge of sound exist ?
Post by: on Sat 20/06/2009 14:34:08
You will need to create all "gauges" individually. There's no way around that. Depending on how many you need, well, it means some work.

Try the following:

a) Create a new GUI. Make it 100 px wide and 30 px high.
b) Set background and border colour to 2113.
c) Place a new button on that GUI, 100w/30h again.
d) Import an image for your "filled gauge", which must fit the button's dimensions (100/30).
e) Name the button btnGauge. YOu don't need an onClick event for it, but a name you will need.

That's basically all you need to set up your gauge. Now to try it out.

Open the game's global script and find the on_key_press function. Add the following
code there (you can copy'n'paste it if your button is named btnGauge, otherwise you need to change the name).


 if (keycode == eKeyA) {
   if (btnGauge.Width > 0) {
     btnGauge.Width--;
   } else {
     Display("You be dead!");
   }
 }
 
 if (keycode == eKeyB)
 {
   if (btnGauge.Width < 100) {
     btnGauge.Width++;
   } else {
     Display("Already at max!");
   }
 }


This allows you to manually change the gauge by bressing A and B. Should work okay; for a nicer look you could create a more elaborate "empty gauge" graphic and set it as the GUI background, obviously.