UTIL ScreenFade: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Ninjaofsauce (talk | contribs) (added examples and categories) |
||
| Line 1: | Line 1: | ||
{{DISPLAYTITLE:UTIL_ScreenFade}} | {{DISPLAYTITLE: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 == | ||
<source lang=cpp> | <source lang=cpp> | ||
| Line 31: | Line 30: | ||
</source> | </source> | ||
== | == Example Uses == | ||
*When firing the [[weapon_ar2]] secondary attack, UTIL_ScreenFade is used to flash white on the player screen.{{hl2}} | |||
*[[weapon_rpg]] as the rocket ignites after launch.{{hl2}} | |||
*[[weapon_flashbang]] {{cs}} | |||
*[[env_fade]] {{hl2}} | |||
== Code Examples == | |||
<source lang=cpp> | <source lang=cpp> | ||
color32_s clr = { 0,0,0,255 }; | color32_s clr = { 0,0,0,255 }; | ||
| Line 48: | Line 52: | ||
UTIL_ScreenFade( pPlayer, red, 1.0f, 0.1f, FFADE_IN ); | UTIL_ScreenFade( pPlayer, red, 1.0f, 0.1f, FFADE_IN ); | ||
</source> | </source> | ||
[[Category:Programming]] | |||
== See Also == | |||
*[[Special Effects]] | |||
[[Category:Programming]][[Category:Weapons programming]] | |||
[[Category:Special Effects]] | |||
[[Category:UTIL]] | [[Category:UTIL]] | ||
Revision as of 00:50, 23 November 2025
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
Example Uses
- When firing the weapon_ar2 secondary attack, UTIL_ScreenFade is used to flash white on the player screen.

- weapon_rpg as the rocket ignites after launch.

- weapon_flashbang

- env_fade

Code 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 );