• HUD, overlaps and transparency
    5 replies, posted
I'm trying to write an xp bar and this is what I came up with [img]http://gyazo.com/67289c699cec733be3a291c1aa9cd95a.png[/img] but as the bar fills up, it obviously covers up the text [img]http://gyazo.com/1290ebc98d57f6ac164e1c987b29e29c.png[/img] obviously I could use a different colour for the text but the perfect outcome would be for when the text is being written over the part thats already painted white, it instead becomes transparent. I'm really not expecting there to be an easy way to do this but if anyone knows I'd greatly appreciate it.
Its easier than you think, just use [b][url=http://wiki.garrysmod.com/?title=Render.SetScissorRect]Render.SetScissorRect [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] And draw the text twice at the same position. Quick explantation. First draw the outline and the white text, then draw the percent bar, after that you set the scissor rect and draw the text with the other color directly on the white one (the scissor rect basicly stops anything outside of the rect from being draw, its used in derma) then do render.SetScissorRect(0,0,0,0,false) If you want to make it transparent you would need to use stencils afaik.
I wouldn't recommend having the text be transparent at any point. It's just a matter of HUD design -- you always want the player to be able to read the text on the bar. If the player was in a white room (like on gm_construct) or any lightly-colored area, it could be difficult to read the text. I would recommend just drawing the text in a different color entirely to solve this problem and ensure consistency.
[QUOTE=Entoros;27309133]I wouldn't recommend having the text be transparent at any point. It's just a matter of HUD design -- you always want the player to be able to read the text on the bar. If the player was in a white room (like on gm_construct) or any lightly-colored area, it could be difficult to read the text. I would recommend just drawing the text in a different color entirely to solve this problem and ensure consistency.[/QUOTE] That's a fair point. I guess I'll just keep it simple then. [editline]9th January 2011[/editline] Instead of making another topic I'll just ask here. I'm working on an inventory system and in the db the inventory will be stored as [code]ak47:1|usp45:1|melon:4[/code] where the number is the quantity. Then when the code is loaded it will be translated into a table but I was wondering what would be the more efficient form to sent to the client, a table or a string, considering the inventory string may get pretty long?
The only way to send a table is to convert to a string and send it (glon + usermessages). Or use datastream, but that does exactly the same thing. If the length of the string will never be more then 256 characters, then your best off using a string & usermessages. If it will be more than 256 characters, you'll either have to use datastream or cut the string up into segments no larger than 256 characters and send them in different usermessages, which is what I think datastream does anyway.
[QUOTE=Ploo;27310268]That's a fair point. I guess I'll just keep it simple then. [editline]9th January 2011[/editline] Instead of making another topic I'll just ask here. I'm working on an inventory system and in the db the inventory will be stored as [code]ak47:1|usp45:1|melon:4[/code] where the number is the quantity. Then when the code is loaded it will be translated into a table but I was wondering what would be the more efficient form to sent to the client, a table or a string, considering the inventory string may get pretty long?[/QUOTE] Just let all items have an index(short) and then sent index:value. That will save alot of usermessages.
Sorry, you need to Log In to post a reply to this thread.