Jump to content

button resolution different


Speak

Recommended Posts

Posted

At each resolution the button is in a different place

local sx, sy = guiGetScreenSize ( ) 
local pX, pY = ( sx / 2 - 620 / 2 ), ( sy /1 - 550 / 2 ) 
local button = guiCreateButton(pX, pY,200,40,"",false); 

I want to stay in the same place in all resolutions

Posted
Ok, give me the resolution in which the button is placed correctly.

is already in the script 800x600x32 fixed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,,

Posted (edited)
local sx, sy = guiGetScreenSize ( ) 
local sizeX, sizeY = 620, 550 -- define your size here 
local pX, pY = ( sx / 2 - sizeX / 2 ), ( sy / 2 - sizeY / 2 ) -- first half of your code was correct, so why did you divide 'sy' by 1? should be 2 like the 'sx' 
local button = guiCreateButton(pX, pY,sizeX,sizeY,"",false); 

Note: It is not going to be the same size for every resolution, its just gonna be at the some position. If you want it to be the same size, you should use 'relative' values instead of 'absolute'.

Edited by Guest
Posted

Instead of saying that, you could perhaps say why not..? If you can't center a window with the correct code I gave you, try this:

https://wiki.multitheftauto.com/wiki/CenterWindow

Copy - paste the whole code from the link I gave you and use it like so:

myWindow = guiCreateWindow ( parameters ) 
centerWindow ( myWindow ) -- Make sure function centerWindow is in your script 

Posted

Try this:

local sx, sy = guiGetScreenSize ( ) 
local x = (11.25*sx) /100 
local y = (54.16*sy) /100 
local button = guiCreateButton(x, y, 200, 40, "", false); 

If it's not the right position, show the x and y positions you've created the button.

Posted

Note that you cant actually make it with one value for all resolutions: i did this and its still not perfect.. so deal with it like that.. (What most varies on a text drawing is scale)

  
if x >= 1025 and y >= 720 then 
dxDrawText(health, x/1.135, y/1.322, x/1, y/1, tocolor(255,255,255,180), 0.43, PodiumFont2, center, center, false,false,true,true) 
elseif x == 1024 and y == 768 then 
dxDrawText(health, x/1.135, y/1.322, x/1, y/1, tocolor(255,255,255,180), 0.4, PodiumFont2, center, center, false,false,true,true) 
elseif x == 800 and y == 600 then 
dxDrawText(health, x/1.135, y/1.322, x/1, y/1, tocolor(255,255,255,180), 0.3, PodiumFont2, center, center, false,false,true,true) 
elseif x == 640 and y == 480 then 
dxDrawText(health, x/1.135, y/1.321, x/1, y/1, tocolor(255,255,255,180), 0.25, PodiumFont2, center, center, false,false,true,true) 
end 

  • Moderators
Posted
Ok, give me the resolution in which the button is placed correctly.

is already in the script 800x600x32 fixed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,,

Wasn't in the script at all lol. Try this then:

local button = guiCreateButton(0.1125, 0.542, 0.25, 0.0667, "", true) 

And voila, it's will be exactly at the same place in all resolutions (and exactly the same place where your code was actually positioning it)

If it's not what you wanted, then please provide screenshot(s).

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...