How to fade a Gui in and out

Started by Dualnames, Wed 25/07/2007 21:59:22

Previous topic - Next topic

Dualnames

I've been trying a lot. I want to make sort of a credits part. Where something is faded in then after a sec it's faded out. If it can be done through a credits module please redirect me to it.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

Well since you specifically asked about a GUI, you could use the GUI.Transparency property...which actually gives (in the manual) an example of how fading could be achieved....

Dualnames

I've tried it.
The GUI is completely fade d out at the beggining(before fade in)
gGui1.Transparancy=100;
The fade out  works.

int trans = gGui1.Transparency;
while (trans < 100) {
  trans++;
  gGui1.Transparency = trans;
  Wait(2);
}

The fade in should be like

int trans = gGui1.Transparency;
while (trans != 0) {
  trans--;
  gGui1.Transparency = trans;
  Wait(2);
}

But it's not working.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

How exactly does it "not work"? Is it not running all the way? Is there no visible change to the transparency? Simply saying it doesn't work is rather vague which makes the problem hard to diagnose.

Khris

FYI, one doesn't need a variable.

Code: ags
  while (gGui1.Transparency<100) {
    gGui1.Transparency++;
    Wait(2);
  }
  Wait(80);
  while (gGui1.Transparency>0) {
    gGui1.Transparency--;
    Wait(2);
  }


This probably won't solve the problem, though.

Ashen

#5
Actually, I think you DO need the variable. Whenever I've tried changing GUI.Transparancy directly in the past, it just locks up (GUI doesn't fade in/out and it's basically on a permenant Wait). The manual says:
Quote
Some rounding is done internally when the transparency is stored -- therefore, if you get the transparency after setting it, the value you get back might be one out. Therefore, using a loop with gInventory.Transparency++; is not recommended as it will probably end too quickly.
I guess something similar is at work?

So you might need the variable but as monkey said, we need a bit more information on what exactly is/isn't happening. For the record, I tried the fadein code you posted and it works perfectly.
I know what you're thinking ... Don't think that.

Dualnames

It opens the gui without fading it then it closes it.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ashen

#7
What colour depth is your game?
I know what you're thinking ... Don't think that.

Ghost

#8
Ashen is right, changing the GUI.Transparency directly doesn't work. You need a variable to change and pass over. You don't need to define the same int trans two times, though. Define it once, later just use it.

Quote from: Dualnames on Wed 25/07/2007 22:05:12
int trans = gGui1.Transparency;
while (trans != 0) {
  trans--;
  gGui1.Transparency = trans;
  Wait(2);
}

I took your code and tried it out in a 16bit game, Dual. Believe it or not, if you replace the !=0 with a >0, it works. Sounds a bit strange- not equal shouldn't be much different from "larger than".
Possibly a quirk in AGS?

Ashen

#9
It works fine for me with '!= 0' - although I'd use '>', personally. It's the 'in a 16-bit game' part that I was getting at. Transparency doesn't work in 256 colour games (I think Lone Case 1 was 256? Can't tell with LC2, but if it is that's the problem right there.)
I know what you're thinking ... Don't think that.

Ghost

It should be the 16bit issue then. To clarify, I used the >0 instantly, out of habit, and when it worked, I thought to have found the error and thus posted "to replace !=".
Sorry for the foggy conclusion.

Shane 'ProgZmax' Stevens

Might also be the Wait delay being too little for you to notice the fade, especially if you have a really fast machine.  Try Wait(10) or even Wait(20) just to make sure it's working before reducing it.

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ghost

Did you try out the new code, as suggested by Ashen and myself, and did you try a longer delay, as suggested by ProgZ?

SMF spam blocked by CleanTalk