Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Edv1983 on Sat 27/08/2011 07:51:04

Title: Making a character fade in after a specific number of loops
Post by: Edv1983 on Sat 27/08/2011 07:51:04
I've tried using the character transparency but i only seem to get him to fade out of sight but not into sight..... or it just doesn't work.


int trans = Jack.Transparency;
while (trans > 85) {
  trans++;
  Jack.Transparency = trans;
  Wait(4);


Any help?  Or is there another way to do this.

In the scene a car pulls up outside the house and I want Jack to appear a couple of seconds after the car stops.
Title: Re: Making a character fade in after a specific number of loops
Post by: monkey0506 on Sat 27/08/2011 07:59:37
The Character.Transparency setting ranges from 0 to 100, in terms of percentage. 0% transparency would make the character fully opaque (fully solidly visible), while 100% transparency would make the character fully transparent (completely invisible).

You said you're trying to make him fade in, but you're increasing his transparency (making him more transparent, i.e. less visible). Also your while loop is checking that the trans variable is > 85 while increasing it. If it ever met that condition then your game would break with a hung loop.

If the character was fully transparent then your loop would work if you were decrementing trans (trans--;), although he would still be at 85% transparency when the fade-in stopped.
Title: Re: Making a character fade in after a specific number of loops
Post by: Dualnames on Sun 28/08/2011 17:44:02

int trans = Jack.Transparency;
float r1;

while (trans > 0) {
  trans--;
  r1=IntToFloat(trans)/20.0;
  Jack.Transparency = trans;
  Wait(FloatToInt(r1,eRoundDown));
}


This will probably make the effect a bit smoother. I haven't tested it, but here you are.
Title: Re: Making a character fade in after a specific number of loops
Post by: picklegreen on Wed 05/10/2011 10:16:52
I tested it, doesn't work.
Title: Re: Making a character fade in after a specific number of loops
Post by: Intense Degree on Wed 05/10/2011 11:25:12
Did you make the character transparent (invisible) before using Dual's code above?

Jack.Transparency = 100;

Do that just before the other code.

Although if you just want him to appear 2 seconds after the car (i.e. not fade in like a ghost), make him invisible as above, then after the car stops...

Wait 80;
Jack.Transparency = 0;