Difference between revisions of "UTIL ScreenFade"

From Valve Developer Community
Jump to: navigation, search
(Created Page)
 
Line 1: Line 1:
 
{{wrongtitle|UTIL_ScreenFade}}
 
{{wrongtitle|UTIL_ScreenFade}}
UTIL_ScreenFade is a UTIL provided to fade a player's screen to a specified color.
+
'''UTIL_ScreenFade''' is a [[UTIL]] provided to fade a player's screen to a specified color.
  
 
== Usage ==
 
== Usage ==

Revision as of 21:00, 10 April 2011

Template:Wrongtitle UTIL_ScreenFade is a UTIL provided to fade a player's screen to a specified color.

Usage

//-----------------------------------------------------------------------------
// Purpose: Fade an entity (player) screen to a specified color.
// Input  : *pEntity - Entity to tell to screen fade on.
// Input  : &color  - Color to fade to
// Input  : fadeTime - Time it takes to fade
// Input  : fadeHold - Time the fade holds for
// Input  : flags - Fade in, Fade Out, Fade_Modulate (don't blend), Fade_StayOut, Fade_Purge (Replaces others)
// Output : 
//-----------------------------------------------------------------------------
void UTIL_ScreenFade( CBaseEntity *pEntity, const color32 &color, float fadeTime, float fadeHold, int flags )
{
	ScreenFade_t	fade;

	UTIL_ScreenFadeBuild( fade, color, fadeTime, fadeHold, flags );
	UTIL_ScreenFadeWrite( fade, pEntity );
}

Fade Flags

#define FFADE_IN			0x0001		// Just here so we don't pass 0 into the function
#define FFADE_OUT			0x0002		// Fade out (not in)
#define FFADE_MODULATE			0x0004		// Modulate (don't blend)
#define FFADE_STAYOUT			0x0008		// ignores the duration, stays faded out until new ScreenFade message received
#define FFADE_PURGE			0x0010		// Purges all other fades, replacing them with this one

Examples

color32_s clr = { 0,0,0,255 };
UTIL_ScreenFade( pPlayer, clr, 0.3, 0, FFADE_IN | FFADE_PURGE );
color32 black = { 0, 0, 0, 255 };
UTIL_ScreenFade( pPlayer, black, 0.1f, 0.0f, (FFADE_OUT|FFADE_STAYOUT) );
// Red damage indicator
color32 red = { 128, 0, 0, 128 };
UTIL_ScreenFade( pPlayer, red, 1.0f, 0.1f, FFADE_IN );