Jump to content

guiGetScreenSize


Recommended Posts

Posted
local sw,sh = guiGetScreenSize() 
guiCreateStaticImage( sw-203, sh-678, sw-1216, sh-618, "logo.png", false) 
function DXtext () 
dxDrawText(tostring "Hello",sw-241,sh-558,sw-634,sh-2,tocolor(148,0,220),1.5,"beckett") 
end 
addEventHandler ( "onClientRender", getRootElement(), DXtext ) 

In this script when I open this script In another resolution logo and text changes their position.

Guest Guest4401
Posted

Because sw & sh will differ depending upon the resolution.

Guest Guest4401
Posted

What was your screen resolution when it was at the correct position?

Posted
  
local x,y = guiGetScreenSize() 
guiCreateStaticImage( x/3.8, y/3.8, x/2.02, y/2, "logo.png", false) 
function DXtext () 
dxDrawText(tostring "Hello",x/3.5, y/3.6, x, y,tocolor(148,0,220),1.5,"beckett") 
end 
addEventHandler ( "onClientRender", getRootElement(), DXtext ) 

This positions is for example, but it still working :)

Guest Guest4401
Posted
Yes but i want it to same in every resolution.

Use relative positions if math with guiGetScreenSize() is too difficult for you.

Guest Guest4401
Posted
local sw,sh = guiGetScreenSize() 
local image = guiCreateStaticImage( sw-203, 90, 150, 150, "logo.png", false) 
  
addEventHandler("onClientRender",root, 
    function() 
        dxDrawText(tostring "Hello",sw-241,210,sw,sh,tocolor(148,0,220),1.5,"beckett") 
    end 
) 

Posted
WidthOfScreen/2-WidthOfWindow/2, HeightOfScreen/2-HeightOfWindow/2 for center screen coordinates
local sw,sh = guiGetScreenSize() 
local w,h = 300,100 
guiCreateStaticImage( sw/2-w/2, sh/2-h/2, w, h, "logo.png", false) 

will on the center

Posted
No no I downt want In center I want it in my cordinates.

You either need to use relative size and position or use fixed position but get its new position for different resolution (using relative values).

If you test this:

local w,h = guiGetScreenSize( ); 
local x,y = 300, 100; 
local img = guiCreateStaticImage( x, y, w, h, "logo.png", false ); 
x, y = guiGetPosition( img, true ); 
outputChatBox( "Relative coords,  x:" .. tostring( x ) .. ";  y: " .. tostring( y ) ); 

You should be able to see its relative coords, then you can use them to display the element at the same position on different resolution.

Posted

Yes when I test it I see a big logo in my center of screen and see relative values. But If I have relative values after what I must do to It where I want in every resolution.

Posted
Yes when I test it I see a big logo in my center of screen and see relative values. But If I have relative values after what I must do to It where I want in every resolution.

Read on relative parameter of guiCreateStaticImage.

Posted
x: 0.21961933374405; y: 0.13020832836628
relative: This is whether sizes and positioning are relative. If this is true, then all x,y,width,height floats must be between 0 and 1, representing measures relative to the parent.
Posted
But if I use relative then in every resolution It is in same?

Have you tried it?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...