Does a module for a gauge of sound exist ?

Started by Kangourou pas sympa, Fri 19/06/2009 22:35:18

Previous topic - Next topic

Kangourou pas sympa

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

Ghost

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

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)

Kangourou pas sympa

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.

Ghost

#3
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).

Code: ags

  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.

SMF spam blocked by CleanTalk