// This value of mFadeFactor will range from 0 to 1. You will need
// code somewhere that is slowly changing this value from 0 up to 1.
// The closer to zero it is, the more faded the text or texture will
// be. As it gets closer to one, the text/texture becomes more solid.
// The code that updates this value is not present in this example.
var float mFadeFactor;
simulated function PostRender(canvas Canvas)
{
local color myColor;
local texture myTexture;
// Style must be translucent for both text and texture fading.
Canvas.Style = ERenderStyle.STY_Translucent;
// Fading in text...
// Set up the base color of the text.
// Choose whatever color you want, except black.
myColor.R = 255;
myColor.G = 128;
myColor.B = 51;
// Set canvas translucency
Canvas.DrawColor = GetFadeColor(myColor, mFadeFactor);
// Set position and draw text (the position used here is just an example)
Canvas.SetPos(Canvas.clipX/2, Canvas.ClipY/2);
Canvas.DrawText("some text...");
// Fading in a texture...
// Just use white as the base color
myColor.R = 255;
myColor.G = 255;
myColor.B = 255;
// Set canvas translucency
Canvas.DrawColor = GetFadeColor(myColor, mFadeFactor);
myTexture = ... // You must set your own texture
// Set position (the position used here is just an example)
Canvas.SetPos((Canvas.clipX*2)/3, (Canvas.ClipY*2)/3);
// Draw Texture (the numbers used here are just an example)
Canvas.DrawTileClipped(myTexture, 64, 64, 0, 0, 64, 64);
}
simulated function color GetFadeColor(color ABaseColor, float AFadeFactor)
{
local color aColor;
// AFadeFactor must be from 0 to 1.
if((AFadeFactor < 0) || (AFadeFactor > 1))
return ABaseColor;
aColor.R = ABaseColor.R * AFadeFactor;
aColor.G = ABaseColor.G * AFadeFactor;
aColor.B = ABaseColor.B * AFadeFactor;
return aColor;
}