Panel/AlphaTo

From Garry's Mod
Revision as of 20:07, 16 January 2020 by XenikayFR (Talk | contribs)
Jump to: navigation, search
 Panel:AlphaTo( )

Contents

Description

Uses animation to transition the current alpha value of a panel to a new alpha, over a set period of time and after a specified delay.

Arguments

number alpha

The alpha value (0-255) to approach.

Arguments

number duration

The time in seconds it should take to reach the alpha.

Arguments

number delay=0

The delay before the animation starts.

Arguments

function callback

The function to be called once the animation finishes. Arguments are:

Examples

Example

Make the derma frame fading out in 1 second.

local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 100, 100 )
DermaPanel:SetSize( 300, 110 )
DermaPanel:SetTitle( "My derma frame" )
DermaPanel:SetDraggable( true )
DermaPanel:MakePopup()

local DermaButton = vgui.Create( "DButton", DermaPanel )
DermaButton:SetText( "Fade out" )
DermaButton:SetPos( 25, 40 )
DermaButton:SetSize( 250, 50 )
DermaButton.DoClick = function()
	DermaPanel:AlphaTo( 0, 1, 0, function() 	
		DermaPanel:Remove() -- Remove the DFrame when the animation is over
	end )
end

Output:

AlphaTo Fade Out.gif
Personal tools
Navigation