Center draw.RoundedBox

[lua]objective01box = vgui.Create( “DFrame” )
objective01box:SetPos( 0, 0 )
objective01box:SetSize( ScrW(), 220 )
objective01box:SetTitle( “” )
objective01box:ShowCloseButton( false )
objective01box:SetVisible( true )
objective01box:SetDraggable( false )
objective01box:SetSize(ScrW(),5)
objective01box:SetContentAlignment( 5 )
function objective01box:Paint( )
draw.RoundedBox( 0, 0, 0, self:GetWide( ), self:GetTall( ), Color( 0, 0, 0, 240 ) )
end[/lua]

Instead of being centered, it is at 0,0. Help?

That’s because you need to do objective box:Center() otherwise its going to be set at position 0,0 which is at the upper left hand corner I believe

edit: just realized you were talking about the draw.roundesbox I’m sorry! You actually going to have to find the measurements for the x and y args I believe.

Well, I want to to scale perfectly for all resolutions possible.
I tried [lua]draw.RoundedBox( 0, 0, ScrH() / 2, self:GetWide( ), self:GetTall( ), Color( 0, 0, 0, 240 ) )[/lua]
But then it does not appear on screen at all, why?

Wait how big do you want the box because you call the size twice?

I’m not sure but why in your code do you have two setsize() functions for your frame?

Ignore that, it was just your everyday oversight… :suicide:

So can you give us the actual code?

Did that fix anything or is the box still not drawing over your frame?

You will need to Center() your frame

It is still broken. It always works unless I set ScrH() for the yPos in the draw rounded box.

helplesskitty, I am using draw rounded box, doing that for the panel, as I expected, does absolutely nothing.

[editline]edit[/editline]
Actually, helplesskitty, after removing the ScrH() / 2 in the actual draw rounded box, it seems to be centered. However, I want it centered vertically and stuff but I want it to be veeery slightly up above the crosshair. I can do this with SetContentAlignment(), but what about Center()?

Basically whatever size you set the Frame too, is what size the roundedbox is allowed to ‘exist’ in, so you have y set to 220 and x is ScrW() yes? so the box should run all across the screen but only 220 up?