Making a character fade in after a specific number of loops

Started by Edv1983, Sat 27/08/2011 07:51:04

Previous topic - Next topic

Edv1983

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.

monkey0506

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.

Dualnames

Code: ags

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


Intense Degree

Did you make the character transparent (invisible) before using Dual's code above?

Code: ags
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...

Code: ags
Wait 80;
Jack.Transparency = 0;



SMF spam blocked by CleanTalk