GuiGetAlpha

From Multi Theft Auto: Wiki
Revision as of 13:38, 26 December 2012 by WolfPire (talk | contribs)
Jump to navigation Jump to search

Alpha represents the transparency of a gui element. This function allows retrieval of a gui element's current alpha.

Syntax

float guiGetAlpha ( element guiElement )

Required Arguments

  • guiElement: The gui element in which you want to retrieve the alpha of.

Returns

This function returns a positive integer in between 0 and 1 of the gui element's current alpha, or false if it could not be retrieved.

Example

This example provides a guiFade function, which allows you to fade in/out a GUI.

function guiFade( gui, state )
	if state == "in" then -- This state will fade IN the GUI
	fadeIn = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it lower the alpha each 50 ms
	alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop
	guiSetAlpha(gui, alpha - 0.1) -- We set the GUI's actual alpha after each loop
	if alpha == 0 then -- If the loop reached "0"...
		killTimer(fadeIn) -- ... We kill the timer
		fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil
		end
	elseif state == "out" then -- This state will fade OUT the GUI
		fadeOut = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it higher the alpha each 50 ms
		alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop
		guiSetAlpha(gui, alpha + 0.1) -- We set the GUI's actual alpha after each loop
		if alpha == 1 then -- If the loop reached "1"...
			killTimer(fadeOut) -- ... We kill the timer
			fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil
		end
	end
end

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows