Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: tiagocorreia on Thu 18/05/2006 12:20:07

Title: MODULE: Fade
Post by: tiagocorreia on Thu 18/05/2006 12:20:07
I've created this module this enable the fade of objects, characters, screen

Currently, I've only implemented for objects, and it is not complete yeat. But for some resaon it is not working correctly. Can anyone take a look and help me to check what is the problem?

My problem is that the object doesn't fade. I do change the transparency values, but for some reason it doesn't chage it. I'm using 32bit objects sprites with alpha transparency.

I'm using version 2.72 RC1

Module Fade version 1.0 (http://www.sirbabyface.net/ags/fade.scm)


Example of usage:
FadeObj.FadeInObject(oTitle, GetGameSpeed() * 4, eBlock);

This will fade the object during 4 seconds, and will wait for it to finish.
Title: Re: MODULE: Fade
Post by: GarageGothic on Thu 18/05/2006 12:39:40
The Transparency function doesn't work for sprites that have alpha channels, sorry
Title: Re: MODULE: Fade
Post by: tiagocorreia on Thu 18/05/2006 12:45:12
Ok, thank you. So I guess this module is not going to be continued. maybe I'll make some changes, since I also want to use it for fade the screen, because I don't like the FadeIn FadeOut functions work.
Title: Re: MODULE: Fade
Post by: GarageGothic on Thu 18/05/2006 13:18:58
I suggested to CJ to add the option to remove the alpha channels when creating a DynamicSprite from an existing 32-bit sprite. Not sure if it got tracker'ered, but if it is implemented it would be an option for you.

Edit: Just did a search and the suggestion is in the tracker at http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=527

Also, for inspiration to your FadeScreen function, check out the entire script of my FadeNonBlocking module below. It needs a few tweaks (such as what happens if you fade out before the screen is faded in entirely), but works nicely as is. It uses a full-screen black GUI and changes its transparency. Of course the color of the GUI could be changed to fade to white, red or whatever instead of black. As the name says, it's not blocking unlike FadeIn/FadeOut, and it allows very slow fades as well.

// Main script for module 'FadeNonBlocking'

int fadeintimer;
int fadeouttimer;
float fadetransparency;
float fademodifier;

function FadeInNonBlocking(int time) {
  fadetransparency = 0.0;
  fadeintimer = time;
  fademodifier = IntToFloat(100)/IntToFloat(time);
}

function FadeOutNonBlocking(int time) {
  fadetransparency = 100.0;
  fadeouttimer = time;
fademodifier = IntToFloat(100)/IntToFloat(time);
}


function repeatedly_execute_always() {
if (fadeintimer > 0) {
    fadetransparency = fadetransparency + fademodifier;
if (fadetransparency <= 100.0) gFadetoblack.Transparency = FloatToInt(fadetransparency);
else gFadetoblack.Transparency = 100;
    fadeintimer--;
    }
  else if (fadeouttimer > 0) {
    fadetransparency = fadetransparency - fademodifier;
if (fadetransparency >= 0.0) gFadetoblack.Transparency = FloatToInt(fadetransparency);
else gFadetoblack.Transparency = 0;
    fadeouttimer--;
    }
}
Title: Re: MODULE: Fade
Post by: tiagocorreia on Fri 19/05/2006 10:26:01
Yes, I already have something similiar to wokr with a GUI, but I would liek to do it with out a GUI. I've to take a look at the dynamic Sprite or graphics, to see what I can do.

About the option to remove the alphachannel, that wont help a lot, since I need the alpha channel and on top of that a new transparency layer should be applied.

I'll have to do the module later, since I've to finish a game until 15 of June.

Thanks fo the help.