|
|
| Line 1: |
Line 1: |
| {{PL/Client function}}
| |
| __NOTOC__
| |
| Ta funkcja pozwala ustawić pozycję elementu DGS.
| |
| ==Składnia==
| |
| <syntaxhighlight lang="lua">
| |
| bool dgsSetPosition ( element theElement, float x, float y, bool relative )
| |
| </syntaxhighlight>
| |
|
| |
|
| ===Wymagane Argumenty===
| |
| <!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
| |
| *'''theElement:''' Element DGS, którego pozycja ma zostać zmieniona.
| |
| *'''x:''' Pozycja w osi ''X''
| |
| *'''y:''' Pozycja w osi ''Y''
| |
| *'''relative:''' Określa, czy wprowadzona pozycja jest w formie względnej. Jeśli ''true'', to wartość powinna znajdować się w przedziale od 0 do 1.
| |
|
| |
| ===Wynik===
| |
| <!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
| |
| Zwraca ''true'' jeśli pozycja została ustawiona poprawnie, lub ''false'' jeśli ustawienie pozycji nie powiodło się.
| |
|
| |
| ==Przykład==
| |
| Ten przykład tworzy label oraz ustawia jego pozycję w miejscu kliknięcia.
| |
| <syntaxhighlight lang="lua">
| |
| DGS = exports.dgs
| |
| -- stworzenie pola tekstowego
| |
| local myLabel = DGS:dgsCreateLabel ( 0, 0, 1, 1, "", true )
| |
|
| |
| function addLabelOnClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )
| |
| if ( clickedElement ) then
| |
| -- pobranie rodzaju elementu
| |
| local elementType = DGS:dgsGetType ( clickedElement )
| |
| -- ustawienie tekstu pola tekstowego
| |
| DGS:dgsSetText ( myLabel, elementType )
| |
| -- zmiana pozycji klikniętego elementu
| |
| DGS:dgsSetPosition ( myLabel, absoluteX, absoluteY, false )
| |
| -- ukrywa label poprzez ustawienie jego tekstu na "" po 5 sekundach od kliknięcia
| |
| setTimer ( DGS:dgsSetText, 5000, 1, myLabel, "" )
| |
| end
| |
| end
| |
| addEventHandler ( "onDgsMouseClick", getRootElement(), addLabelOnClick )
| |
| </syntaxhighlight>
| |
|
| |
| ==Zobacz również==
| |
| <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
| |
| {{DGSFUNCTIONS_PL}}
| |