MODULE: Fade

Started by tiagocorreia, Thu 18/05/2006 12:20:07

Previous topic - Next topic

tiagocorreia

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


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

This will fade the object during 4 seconds, and will wait for it to finish.

GarageGothic

The Transparency function doesn't work for sprites that have alpha channels, sorry

tiagocorreia

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.

GarageGothic

#3
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.

Code: ags
// 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--;
    }
}

tiagocorreia

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.

SMF spam blocked by CleanTalk