DPropertySheet.CrossFade

From GMod Wiki

Jump to: navigation, search
Function
Syntax DPropertySheet:CrossFade( Table anim, Integer delta, Table data )
Description:
anim is an animation object created by Derma_Anim, delta is some kind of multiplier and data is a table containing the panels to fade and more
Returns: Nil
In Object: DPropertySheet
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DPropertySheet.CrossFade]DPropertySheet.CrossFade [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Source code

DescriptionThe code as defined in lua/vgui/DPropertySheet.lua
Used onNewerClient.png
Code
function PANEL:CrossFade( anim, delta, data )
 
	local old = data.OldTab:GetPanel()
	local new = data.NewTab:GetPanel()
 
	if ( anim.Finished ) then
 
		old:SetVisible( false )
		new:SetAlpha( 255 )
 
		old:SetZPos( 0 )
		new:SetZPos( 0 )
 
	return end
 
	if ( anim.Started ) then
 
		old:SetZPos( 0 )
		new:SetZPos( 1 )
 
		old:SetAlpha( 255 )
		new:SetAlpha( 0 )
 
	end
 
	old:SetVisible( true )
	new:SetVisible( true )
 
	new:SetAlpha( 255 * delta )
 
end
OutputN/A


Example

DescriptionExample of how to use this effect, as defined in lua/vgui/DPropertySheet.lua
Used onNewerClient.png
Code
function PANEL:Init()
	//... - Code is removed to preserve space.
 
	self.animFade = Derma_Anim( "Fade", self, self.CrossFade )
 
	//... - Code is removed to preserve space.
 
end
function PANEL:SetActiveTab( active )
 
	//... - Code is removed to preserve space.
 
	self.animFade:Start( self:GetFadeTime(), { OldTab = self.m_pActiveTab, NewTab = active } )
 
	//... - Code is removed to preserve space.
 
end
function PANEL:Think()
 
	self.animFade:Run()
 
end // No code ommited in that hook... It's just that.
 
OutputCross-fading screens (well, that is when you're using it in


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox