• Upside-down Health Bar
    3 replies, posted
I made a health bar that works perfectly although when the player loses health the bar gets shorter from the bottom rather than the top. I suppose this isn't really something wrong it's just how it works. Is there any way I could reverse it? [CODE] local hp = LocalPlayer():Health() / 100 local hpbar = 80 * hp draw.RoundedBox( 1, 60, ScrH() - 70, 200, 40, Color( 0, 0, 0, 200 ) ) if hpbar > 80 then draw.RoundedBox( 1, 64, ScrH() - 66, 80, 32, Color( 200, 0, 0, 200 ) ) else draw.RoundedBox( 1, 64, ScrH() - 92, 60, hpbar, Color( 200, 0, 0, 200 ) ) end draw.DrawText( tostring( LocalPlayer():Health() ), "CustomFont", 20, ScrH() - 60, color_white, TEXT_ALIGN_LEFT )[/CODE]
I had this exact issue when I was trying to make a HUD, and I've really got no idea how to fix it either.
Try this out. [code] local hp = LocalPlayer():Health() / 100 local hpbar = 80 * hp draw.RoundedBox( 1, 60, ScrH() - 70, 200, 40, Color( 0, 0, 0, 200 ) ) if hpbar > 80 then draw.RoundedBox( 1, 64, ScrH() - 66, 80, 32, Color( 200, 0, 0, 200 ) ) else draw.RoundedBox( 1, 64, (ScrH() - 92) + (80 - hpbar), 60, hpbar, Color( 200, 0, 0, 200 ) ) end draw.DrawText( tostring( LocalPlayer():Health() ), "CustomFont", 20, ScrH() - 60, color_white, TEXT_ALIGN_LEFT ) [/code]
[QUOTE=RedXVIII;50611697]Try this out. [code] local hp = LocalPlayer():Health() / 100 local hpbar = 80 * hp draw.RoundedBox( 1, 60, ScrH() - 70, 200, 40, Color( 0, 0, 0, 200 ) ) if hpbar > 80 then draw.RoundedBox( 1, 64, ScrH() - 66, 80, 32, Color( 200, 0, 0, 200 ) ) else draw.RoundedBox( 1, 64, (ScrH() - 92) + (80 - hpbar), 60, hpbar, Color( 200, 0, 0, 200 ) ) end draw.DrawText( tostring( LocalPlayer():Health() ), "CustomFont", 20, ScrH() - 60, color_white, TEXT_ALIGN_LEFT ) [/code][/QUOTE] Yeah, that did it
Sorry, you need to Log In to post a reply to this thread.