Hi guys I have a quick question/ issue which someone can hopefully help me with.
I have some text on a hud for a small project I am working on. But when I change the resolution of my screen it either goes off the screen, or it ends up on a random spot on the screen. Here is my code, I hope someone can help me.
[code]
surface.SetTextPos(220, 110, ScrW()/1, ScrH()/1)
surface.SetFont("MyFont4")
surface.DrawText("Deaths:")
[/code]
Thanks
Duby
[lua]
surface.SetTextPos(220, 110, ScrW()/1, ScrH()/1)
[/lua]
3rd and 4th value aren't needed, anyway, remember, 5/1 = 5, 4/1 = 4 (You're dividing a number by 1, don't know why)
In the first and second value you must use the ScrW and ScrH vars
Like
[lua]
surface.SetTextPos(ScrW()/10, ScrH()/10)
[/lua]
And that should place the text in the left up corner
[QUOTE=gonzalolog;45266027][lua]
surface.SetTextPos(220, 110, ScrW()/1, ScrH()/1)
[/lua]
3rd and 4th value aren't needed, anyway, remember, 5/1 = 5, 4/1 = 4 (You're dividing a number by 1, don't know why)
In the first and second value you must use the ScrW and ScrH vars
Like
[lua]
surface.SetTextPos(ScrW()/10, ScrH()/10)
[/lua]
And that should place the text in the left up corner[/QUOTE]
It already works, but changing the resolution screws it up.
How to hard-code the screen positions / sizing of vgui while using a modifier so it appears the same on all screen-sizes: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html[/url]
Alternatively, you could do something like : [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/creating_shapes_using_poly.lua.html[/url]
where when the screensize changes, it updates the shape...
I'd recommend modifiers, especially if you're new to vgui / hud, because you can hard-code the positions of everything as long as you list the resolution you used to design it ( so it can calculate a modifier to multiply the values against to make it bigger > 1, smaller < 1 or the same size == 1 )
Wow ok that is what I needed! A clear and concise way to do this with instructions to teach me! Thanks a lot ! :)
Sorry, you need to Log In to post a reply to this thread.