A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Advanced HP Bar

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    26

    Thumbs up Advanced HP Bar

    (didnt know if i should post @as2.0 or gaming/move if needed)

    Hey,

    i have been making a hp bar
    i am newbie to flash il try to explain the problem

    when my bar gets hit it goes down the width the same ammount of damage
    so if i got 100hp i got 100width it hits the bar 10 then i got 90width

    yey i got a hp bar!

    but now what happens when your character gets upgraids and reaches 1k hp?
    then my bar is 1000width also....thats a bit of a problem as i want the bar to be 100width for max hp and 0width for zero hp

    evrywhere tuts about hp bars but no one tells me about a hp bar using differnd hp's

    any nice codes to fix this? i dont need advanced stuf any simple will do

    so when i have:
    200 hp the bar stil has a 100width and will just go down 0,5width when its hit by 1 damage

    400 hp the bar stil has a 100width and will just go down 0,25width when its hit by 1 damage

    275071820975 hp the bar stil has a 100width and will just go down
    3,635414186071125537616512665e-10width when its hit by 1 damage

    thx in advance

  2. #2
    Member
    Join Date
    Jan 2011
    Posts
    32
    This is pretty easy to handle. Just set the bar width to the percentage of HP remaining. For example:
    actionscript Code:
    hp_bar._width = Int(hp_current / hp_max * 100);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center