Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Ubel on Sun 03/04/2005 13:26:35

Title: FadeObject function won't work (SOLVED)
Post by: Ubel on Sun 03/04/2005 13:26:35
Ok, since there didn't seem to be any script for fading objects I tried to do one myself:

int trnsp;

function FadeObjectOut (int object) {
  while (trnsp <= 100) {
    SetObjectTransparency (object, trnsp);
    trnsp += 1;
    Wait (1); }
}

function FadeObjectIn (int object) {
  while (trnsp >= 0) {
    SetObjectTransparency (object, trnsp);
    trnsp -= 1;
    Wait (1); }
}

Now, the first one works but I can't get the second one to work. When I tried it, my game crashed.

What's wrong with it?
Title: Re: FadeObject function wont work.
Post by: DoorKnobHandle on Sun 03/04/2005 13:29:34
Well, how did it crash? Any error messages?

Looks allright, since it is basically the same than the first function except it goes the other way...
Title: Re: FadeObject function wont work.
Post by: Ubel on Sun 03/04/2005 13:35:52
Oh yeah, forgot to show you the error message :P

Error: SetObjectTransparent: tranparency value must be between 0 and 100

I don't get it. It IS between 0 and 100. Isn't it?
Title: Re: FadeObject function wont work.
Post by: DoorKnobHandle on Sun 03/04/2005 13:39:02
try that:


function FadeObjectIn (int object) {
trnsp = 100;
  while (trnsp > 0) {
    SetObjectTransparency (object, trnsp);
    trnsp -= 1;
    Wait (1); }
}


notice that I got rid of the >= in the while loop and that I put simply a safety command trnps = 100; at the beginning of the function.. you could also simply use if conditions to check if trnsp is between 0 and 100...
Title: Re: FadeObject function wont work.
Post by: Ubel on Sun 03/04/2005 13:42:57
Yes, now it works! Thank you very much! :)