While using draw/surface, you must change the position of EVERYTHING manually instead of having their position change with parents. Along with aligning, it can be a real pain. Is there a way around setting everything individually, and instead having parents (or at least a system like it)?
you can use panels, which may be better depending on what you’re doing
I’m talking HUDs… You know, with HUDPaint…
Don’t make huds with pure drawing functions unless you like massive boilerplate code and reinventing the wheel.
Panels are made for stuff like this, use them.
I would still recommend using VGUI elements so you can take advantage of their sizing/scaling/docking.
You just hide the panel and then call :PaintAt(x,y) during HUDPaint.
Otherwise you need to basically recreate your own gui system, or at least the maths behind the parenting system of it.
Just store x, y in a variable and do some basic math so all you have to do is change your variable to move everything much like parenting it would do.
I tried using VGUI once for a HUD.
It didn’t go so well… It only updated once every 3 seconds (vgui doesn’t update every frame I had to use workaround) and such
You must have been doing something wrong.
Update the GUI only when you need to
(Player takes damage, Player shoots gun)
That doesn’t even make sense.
Think is called every think (every frame unless set otherwise) and paint is called every frame.
Use helper functions… Turn repetitive statements into helpers… If you use draw to build a specific “thing” such as a progress bar, etc… Also turn those into helpers. Use simple arguments, x, y, w, h, whatever…
Example: Creating a table once, drawing it and only updating the table when resolution changes…
Simplify ( read the url posts ): https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/another_tilted_health_bar.lua.html
It isn’t good to repeat code, it confuses things in production code; for learning repetitions can be useful.
What I meant is at the time I didn’t know how to do actual HUDs. So I did a crappy timer thing where it gets removed and added every 3 seconds. Why every 3 seconds? Because I didn’t know about using the initialize function for fonts…