DgsGetScreenSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (little correction)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
This function is a replica of [[[guiGetScreenSize]]. In order to satisfy the needs of developers, the function exists here.
This function is a replica of [[guiGetScreenSize]]. In order to satisfy the needs of developers, the function exists here.


==Syntax==  
==Syntax==  
Line 7: Line 7:
float, float dgsGetScreenSize()
float, float dgsGetScreenSize()
</syntaxhighlight>
</syntaxhighlight>
{{DGS/OOP|
    Note = The returned value it's a [[Vector2]]|
    Method = '''dgsRootInstance''':getScreenSize
}}


===Returns===
===Returns===
Line 28: Line 32:
</syntaxhighlight>
</syntaxhighlight>


==See Also==
=See Also=
{{DGSFUNCTIONS}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>==
{{DGS General Functions}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>==
{{DGS Events/General}}

Latest revision as of 22:38, 3 May 2021

This function is a replica of guiGetScreenSize. In order to satisfy the needs of developers, the function exists here.

Syntax

float, float dgsGetScreenSize()

DGS OOP Syntax Help! I don't understand this!

Note: The returned value it's a Vector2
Method: dgsRootInstance:getScreenSize(...)

Returns

This returns two floats representing the player's screen resolution, width and height.

Example

This example checks whether a player is using a low resolution, and warns them that GUI may appear incorrect.

--setup a function when the resource starts
DGS = exports.dgs

function checkResolutionOnStart ()
	local x,y = DGS:dgsGetScreenSize() --get their screen size
	if ( x <= 640 ) and ( y <= 480 ) then --if their resolution is lower or equal to 640x480
		--warn them about GUI problems.
		outputChatBox ( "WARNING: You are running on a low resolution.  Some GUI may be placed or appear incorrectly." )
	end
end
--attach the function to the event handler
addEventHandler ( "onClientResourceStart", resourceRoot, checkResolutionOnStart )

See Also

General Functions

General Events