screen size

Started by MEGAMIND, Jun 17, 2018, 03:09 PM

Previous topic - Next topic

MEGAMIND

hello there fellow comunity members

i little question, all these years i've been thinking that this code is the reason to adjust / get screen size of every pc /everyone

sW <- GUI.GetScreenSize().X;
sH <- GUI.GetScreenSize().Y;

but what ever i code using gui it show better in my pc but not in other systems idk how or what is the problem to get the right
vectors of screen or coords.

talking about them every one sees them differently

MEGAMIND

Quote from: vitogta on Jun 17, 2018, 03:37 PMIt's totally depends of your code. I personally use height (Y) as the base value in most of cases. And I never use any magical numbers like this
local x = floor( X*sX/1920 );
 local y = floor( Y*sY/1080 );
Because different people are using different display's aspect ratio.
exactly thats what i ment so this will obviously look bad in some cases
QuoteBecause different people are using different display's aspect ratio.
so any solution to that

DizzasTeR

Yes, use relative values. Take your left-most side of screen as (0, 0) and most right side as (1, 1). This means the least value of your ui positions/scale can be 0 and max can be 1. Then jump ingame and do
_Screen <- GUI.GetScreenSize();
myLabel <- GUILabel(VectorScreen(_Screen.X*0.5, _Screen.Y*0.5), ...)
Here no matter what resolutions player is using, 640x480, 800x600, 1024x768, and so on, on every resolution, the label will draw at center because anything times 0.5 is half, so no matter what X screen of player is, it'll get the half, same for Y.

NicusorN5

For me it feels easier to use _Screen.X / 2 .