You need to position it with fractions of ScrW() and ScrH(), as Crazy said. Any additions or subtractions would cause it to vary on different resolutions.
[QUOTE=MakeR;20958124]You need to position it with fractions of ScrW() and ScrH(), as Crazy said. Any additions or subtractions would cause it to vary on different resolutions.[/QUOTE]
So, you're saying if I did something like ScrW() / 2 - 300, it would be different on each resolution? And then if I did something like ScrW() / 5 it would be fine? And, would using multiplication work too?
Example:
ScrW() * .05
Yes, that's what I am saying.
Yes multiplication works too.
Ok, problem. Here is my code for just the text that displays the money:
[lua]draw.SimpleText( LocalPlayer():GetNetworkedInt( "Money" ), "TextFontHUD", ScrW() / 2 * 0.625, ScrH() / 2 * 1.775, Color( 255, 255, 255, 200 ) )[/lua]
And, for some reason, when I go to a different resolution in GMod, it is not in the same position. Same with everything else, they are not in the same width or height.
Sorry, didn't mean to reply to my other post. I meant to edit.
If you change to a widescreen resolution it will be strectched.
[editline]02:27PM[/editline]
And text text probably needs to be scaled too.
Explain why the text would need to be scaled, sounds like... it's not needed?
[QUOTE=aualin;20973137]Explain why the text would need to be scaled, sounds like... it's not needed?[/QUOTE]
The text will be bigger on smaller resolutions, scaling the text will make it the same.
Can anyone help me? I changed the codes... Here is the code I use now for money:
[lua]draw.SimpleText( LocalPlayer():GetNetworkedInt( "Money" ), "TextFontHUD", ScrW() * 0.20, ScrH() * 0.885, Color( 255, 255, 255, 200 ) )[/lua]
As I said, for something you want to not scale with change in resolution but stay in the same position, subtract from Scr*() for the RIGHT HAND of the screen. For the LEFT HAND, add to 0.
[QUOTE=Disseminate;20977175]As I said, for something you want to not scale with change in resolution but stay in the same position, subtract from Scr*() for the RIGHT HAND of the screen. For the LEFT HAND, add to 0.[/QUOTE]
[QUOTE=MakeR;20958124]You need to position it with fractions of ScrW() and ScrH(), as Crazy said. Any additions or subtractions would cause it to vary on different resolutions.[/QUOTE]
This. Using fractions and multiplication makes it vary too.
Which parts are wrong?
[QUOTE=yoBrelliKX;20978123]Which parts are wrong?[/QUOTE]
That is what I am trying to figure out. It's just that when I go to a different resolution, the HUD is not in the same position as the other resolution.
[QUOTE=wakeboarderCWB;20978260]That is what I am trying to figure out. It's just that when I go to a different resolution, the HUD is not in the same position as the other resolution.[/QUOTE]
Post some images.
This is for 1024x768 ( 4:3 )
[img]http://i972.photobucket.com/albums/ae209/wakeboarderCWB/Killas_GM/gm_construct0004.jpg[/img]
This is for 1680x1050 ( 16:10 )
[img]http://i972.photobucket.com/albums/ae209/wakeboarderCWB/Killas_GM/gm_construct0003.jpg[/img]
I have a 1680x1050 monitor. I positioned the HUD while GMod was using the 1024x768 resolution.
Looks like you are not scaling the width and height.
You need to scale the sizes, not just the positions, with ScrW() and ScrH().
To scale the text you could do like this.
[lua]
function GM:Initialize ()
RunConsoleCommand( "gm_clearfonts" )
surface.CreateFont( "Arial", ScreenScale( 7.5 ), 1000, true, true, "TextFontHUD" )
end
[/lua]
[QUOTE=yoBrelliKX;20990677]To scale the text you could do like this.
[lua]
function GM:Initialize ()
RunConsoleCommand( "gm_clearfonts" )
surface.CreateFont( "Arial", ScreenScale( 7.5 ), 1000, true, true, "TextFontHUD" )
end
[/lua][/QUOTE]
Didn't gm_clearfonts remove all fonts from memory? Why would you want to do that, it'd cause a crapload of errors!
[QUOTE=esalaka;20991334]Didn't gm_clearfonts remove all fonts from memory? Why would you want to do that, it'd cause a crapload of errors![/QUOTE]
I'm not sure it would cause errors, it may just cause all fonts (apart from any created after the fonts are cleared) to show as the default. It still isn't a very good thing to do.
So I have to scale the sizes of the boxes too? Like this?:
[lua]draw.RoundedBox( 6, ScrW() * 0.25, ScrH() * 0.865,ScrW() / 2, ScrH() / 2, Color( 0, 0, 0, 200 ) )[/lua]
(Just an example. )
Yes, all positions and sizes should be scaled to the screen size.
[QUOTE=MakeR;20991523]Yes, all positions and sizes should be scaled to the screen size.[/QUOTE]
Ok. I will try it. Hopefully this will make my hud same positions.
[QUOTE=MakeR;20991400]I'm not sure it would cause errors, it may just cause all fonts (apart from any created after the fonts are cleared) to show as the default. It still isn't a very good thing to do.[/QUOTE]
I've tried it. Causes Lua errors when the surface library tries to use nonexistent fonts.
[QUOTE=esalaka;20991587]I've tried it. Causes Lua errors when the surface library tries to use nonexistent fonts.[/QUOTE]
Oke.
How would I scale this to size? This is the code I use for HP bar.
[lua]local hp = ( LocalPlayer():Health() * 5 ) + 10[/lua]
Multiply that by 1/1024*ScrW(). Or something.
[QUOTE=Entoros;20729752][code]panel:SetPos( 30, ScrW() - 100 )[/code][/QUOTE]
Scr[highlight]W[/highlight]()?
Replace that with an H.
[QUOTE=lavacano;20994699]Scr[highlight]W[/highlight]()?
Replace that with an H.[/QUOTE]
I'm past that. Read my last post, like 2 above yours.
Can anyone help me? Size this code to player's screen?:
[lua]local hp = ( LocalPlayer():Health() )[/lua]
Sorry, you need to Log In to post a reply to this thread.