papam77 Posted July 12, 2013 Share Posted July 12, 2013 Hello, i wanna do something with the dx, but i don't know how to make it relative, it's not same as gui. Can someone help me ? Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 use guiGetScreenSize and maths, that's all you need. Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 function draw() local x,y = guiGetScreenSize() x = 1920 y = 1080 dxDrawText ( "Ahoj",631.6,611.0,732.0,766.0,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,false) end addEventHandler ( "onClientResourceStart", draw ) So this will be for every resolution ? Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 That doesn't make sense.. local x,y = guiGetScreenSize() dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,false) This will draw the text at the centre of the screen (it will start at the centre). Btw. you got error in your addEventHandler... check the syntax on wiki. Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 and tell me why this x/2,y/2,x/2,y/2 Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 And why /2 ? Why not /3 ? Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 What's your grade from maths? ... Why would you divide it by 3 if you want centre? I can't explain it, its basic maths and logic as well Link to comment
bandi94 Posted July 12, 2013 Share Posted July 12, 2013 What's your grade from maths? ...Why would you divide it by 3 if you want centre? I can't explain it, its basic maths and logic as well My math grade is 12 class. And i realy don't get your "/2". He asked how to make it relative not how to make it centered and the size half of the resolution.... How to make it : place the window where you want. Like 400,300 on 1152x864 resolution. After that make the math using calculator. X = 400/1152 Y = 300/864 Then in dxDraw you put. dxDrawImage(ScreenW*X,ScreenH*Y,.......) this will be at the same place on every resolution. I hope you get it. Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 That was just an example. If he had read the wiki he would find all you posted here in the guiGetScreenSize documentation, it's nicely explained there. Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 bandi94, Thank you very much MIKI785, The code which you've gave me, it's show the image only for 1sec and then is image deleted, but why? Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 You probably didn't put the event handler on that function. Post the code. Link to comment
bandi94 Posted July 12, 2013 Share Posted July 12, 2013 IF you don't remove the "OnClientRender" then must show of not to disapear. Make shure "local x,y = guiGetScreenSize()" is outside of the function. Or post the code then i can help you. Link to comment
HunT Posted July 12, 2013 Share Posted July 12, 2013 I use the Gui Editor for get the relative position. Example i make the label for get the relative position type : 0.49, 0.65, 0.13, 0.03 ok so . . . If i want use this on dxdraw i make this local x,y = guiGetScreenSize() a = 0.49 b = 0.65 c = 0.13 d = 0.03 dxDrawText ( "text", a*x , b*y , c*x , d*y , ........... -- is only example Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 function design () local x,y = guiGetScreenSize() dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) end addCommandHandler ("test", design ) Link to comment
bandi94 Posted July 12, 2013 Share Posted July 12, 2013 function design () local x,y = guiGetScreenSize() dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) end local on=false function toggle() if not on then addEventHandler ( "onClientRender", root, design ) on=true else removeEventHandler ( "onClientRender", root, design ) on=false end end addCommandHandler ("test", toggle ) P.S DxFunction's need "addEventHandler ( "onClientRender", root, function)" and not CommandHandler or other event's Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 Now i don't see it. 0 Errors 0 Warnings Link to comment
bandi94 Posted July 12, 2013 Share Posted July 12, 2013 Now i don't see it.0 Errors 0 Warnings Then try it simpel. function design () local x,y = guiGetScreenSize() dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) end addEventHandler ( "onClientRender", root, design ) P.S it should work the first one to : first "test" command = show it , secound "test" command hide it Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 There's no need of getting the resolution every frame. Put the x, y = guiGetScreenSize() at the top of the script. Link to comment
papam77 Posted July 12, 2013 Author Share Posted July 12, 2013 But here is little problem. function design () local x,y = guiGetScreenSize() a = 0.23 b = 0.21 c = 0.19 d = 0.04 dxDrawText ( "TEXT",a*x,b*x,c*x,d*x,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) end addEventHandler ( "onClientRender", root, design ) http://eag-gaming.eu/uploads/problemeeee.png Label output: guiCreateLabel(0.23, 0.21, 0.19, 0.04, "", true) So why it isn't on the label's place? Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 Dont double post! The problem is that youre using screen width (x) to calculate positions on Y axis... 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