GuiGetAlpha: Difference between revisions
Jump to navigation
Jump to search
m (→See Also) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float guiGetAlpha ( element guiElement ) | float guiGetAlpha ( element guiElement ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[GUI widgets|GuiElement]]:getAlpha|alpha|guiSetAlpha}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 15: | Line 16: | ||
==Example== | ==Example== | ||
This example provides a '' | This example provides a ''guiFade'' function, which allows you to fade in/out a GUI. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function guiFade( gui, state ) | ||
if 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"... | |||
guiSetVisible(gui, false) -- We set the GUI visibility to 0 so it won't be clickable or editable | |||
killTimer(fadeIn) -- ... We kill the timer | |||
fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil | |||
end | end | ||
elseif state == " | elseif state == "out" then -- This state will fade OUT the GUI | ||
guiSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" | |||
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"... | |||
guiSetAlpha ( | killTimer(fadeOut) -- ... We kill the timer | ||
fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil | |||
if | |||
-- | |||
end | end | ||
end | end | ||
end | end | ||
-- NOTE: If you're using a button to pop up the GUI-Element. Use "guiSetEnabled" along with the button. You'll have also to set a timer in order to disable it by the time it fades, either way it will bug. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{GUI_functions}} | {{GUI_functions}} | ||
{{GUI_events}} |
Latest revision as of 17:15, 21 November 2018
Alpha represents the transparency of a gui element. This function allows retrieval of a gui element's current alpha.
Syntax
float guiGetAlpha ( element guiElement )
OOP Syntax Help! I don't understand this!
- Method: GuiElement:getAlpha(...)
- Variable: .alpha
- Counterpart: guiSetAlpha
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"... guiSetVisible(gui, false) -- We set the GUI visibility to 0 so it won't be clickable or editable 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 guiSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" 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 -- NOTE: If you're using a button to pop up the GUI-Element. Use "guiSetEnabled" along with the button. You'll have also to set a timer in order to disable it by the time it fades, either way it will bug.
See Also
General functions
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign
Windows
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel