..:D&G:.. Posted August 16, 2015 Share Posted August 16, 2015 Hello guys, I am trying to make a small image in the middle right part of the screen, but I keep bumping on an issue. The image is fine for me, but for a friend with a bigger resolution, he gets it more to the left and a bit longer to the right Any ideas? local x, y = guiGetScreenSize() currencyWindow = guiCreateStaticImage(x/2 + 370, y/2, x/7.2, y/7, ":guieditor/images/examples/fereastra.png", false) Link to comment
Ab-47 Posted August 16, 2015 Share Posted August 16, 2015 Try using this: local screenW, screenH = guiGetScreenSize() function centerWindow(window_element) local windowW,windowH=guiGetSize(window_element,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(window_element,x,y,false) end Call the function with centerWindow(yourwindow) Link to comment
MAB Posted August 16, 2015 Share Posted August 16, 2015 [quote name=..&G:..]Hello guys, I am trying to make a small image in the middle right part of the screen, but I keep bumping on an issue. The image is fine for me, but for a friend with a bigger resolution, he gets it more to the left and a bit longer to the right Any ideas? local x, y = guiGetScreenSize() to make any dx element fixed for all screens do that.. for more information go to tutorials forum and look at my dx tutorial.. local sw, sh = guiGetScreenSize() -- get the screen size of the player... local x,y = (sw/1280),(sh/768) -- my resolution is 1280x768 so that is what i do... i do / my screen width and / my screen height ... use yours function draw () -- ur image positions without any math stuff... currencyWindow = guiCreateStaticImage(x*postionOne, y*positionTwo, x*positionThree, y*positionFour, ":guieditor/images/examples/fereastra.png", false) end -- now all people will see the image like u see it.. any one except the very low resolution ones there will be a small defferance... Link to comment
..:D&G:.. Posted August 16, 2015 Author Share Posted August 16, 2015 Try using this: local screenW, screenH = guiGetScreenSize() function centerWindow(window_element) local windowW,windowH=guiGetSize(window_element,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(window_element,x,y,false) end Call the function with centerWindow(yourwindow) I did this: function centerWindow(window_element) local windowW,windowH = guiGetSize(window_element,false) local x, y = (screenW-windowW)/2, (screenH-windowH)/2 guiSetPosition(window_element, x+440, y, false) end With the size of the gui element beeing this: 141, 121 the x+440 made the guy element perfect on the middle right side of the screen, but my friend with a higher resolution still seens the gui element more to the left, away from the right side of the screen.. ----------------------- to make any dx element fixed for all screens do that.. for more information go to tutorials forum and look at my dx tutorial.. local sw, sh = guiGetScreenSize() -- get the screen size of the player... local x,y = (sw/1280),(sh/768) -- my resolution is 1280x768 so that is what i do... i do / my screen width and / my screen height ... use yours function draw () -- ur image positions without any math stuff... currencyWindow = guiCreateStaticImage(x*postionOne, y*positionTwo, x*positionThree, y*positionFour, ":guieditor/images/examples/fereastra.png", false) end -- now all people will see the image like u see it.. any one except the very low resolution ones there will be a small defferance... The problem is I don't use DX. I have too many small elements that I can't take my time with, so I make them a child of the bigger element (window image)... Link to comment
LoOs Posted August 16, 2015 Share Posted August 16, 2015 Better to use dx This is an example with center : local x, y = guiGetScreenSize() local rx, ry = (x/800), (y/600) function dx () dxDrawLine(rx*473 - 1, ry*137 - 1, rx*473 - 1, ry*577, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(rx*811, ry*137 - 1, rx*473 - 1, ry*137 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(rx*473 - 1, ry*577, rx*811, ry*577, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(rx*811, ry*577, rx*811, ry*137 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(rx*473, ry*137, rx*338, ry*440, tocolor(127, 126, 126, 170), false) end It's not difficult they are easy to use , and I advise you I will help you in the piece Any Problem ? Link to comment
..:D&G:.. Posted August 16, 2015 Author Share Posted August 16, 2015 Better to use dx This is an example with center : local x, y = guiGetScreenSize() local rx, ry = (x/800), (y/600) function dx () dxDrawLine(rx*473 - 1, ry*137 - 1, rx*473 - 1, ry*577, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(rx*811, ry*137 - 1, rx*473 - 1, ry*137 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(rx*473 - 1, ry*577, rx*811, ry*577, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(rx*811, ry*577, rx*811, ry*137 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(rx*473, ry*137, rx*338, ry*440, tocolor(127, 126, 126, 170), false) end It's not difficult they are easy to use , and I advise you I will help you in the piece Any Problem ? Oh, I get it now. I only have to add "rx*" to the size and possition of the dx on my resolution Didn't know it was that easy, thanks a lot ! But I got another problem. The dx elements only render when I use "onClientRender". I used to use "onClientResourceStart" but the dx appears for only 1 seconds and disappears... Any ideas? EDIT--- Fixed! Link to comment
..:D&G:.. Posted August 16, 2015 Author Share Posted August 16, 2015 Um... I just bumped into an issue again... On my screen (1024x768) I see it perfect, like this: And my friend, with a resolution of 1440x900 sees it like this: local x, y = guiGetScreenSize() local rx, ry = (x/1024), (y/768) dxDrawRectangle(rx*883, ry*285, rx*141, ry*121, tocolor(0, 0, 0, 150), false) dxDrawImage(rx*886, rx*329, rx*30, rx*34, "images/dollar.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText(playerEurosValue, rx*922 - 1, rx*300 - 1, rx*1007 - 1, rx*318 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) Any ideas? Link to comment
LoOs Posted August 16, 2015 Share Posted August 16, 2015 Good , and Add function and addEventHandler("onClientRedner",root, be # local x, y = guiGetScreenSize() local rx, ry = (x/1024), (y/768) addEventHandler("onClientRender",root, function () dxDrawRectangle(rx*883, ry*285, rx*141, ry*121, tocolor(0, 0, 0, 150), false) dxDrawImage(rx*886, rx*329, rx*30, rx*34, "images/dollar.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText(playerEurosValue, rx*922 - 1, rx*300 - 1, rx*1007 - 1, rx*318 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) end) Any Problem ? Skype : abdallah_2091 Link to comment
..:D&G:.. Posted August 16, 2015 Author Share Posted August 16, 2015 Good , and Add function and addEventHandler("onClientRedner",root, be # local x, y = guiGetScreenSize() local rx, ry = (x/1024), (y/768) addEventHandler("onClientRender",root, function () dxDrawRectangle(rx*883, ry*285, rx*141, ry*121, tocolor(0, 0, 0, 150), false) dxDrawImage(rx*886, rx*329, rx*30, rx*34, "images/dollar.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText(playerEurosValue, rx*922 - 1, rx*300 - 1, rx*1007 - 1, rx*318 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) end) Any Problem ? Skype : abdallah_2091 You don't get it I managed to make it work, but me and my friend have different resolutions, and he sees it in a different way than me... I added you on skype btw Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now