A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Life Progressbar problem

  1. #1
    MindGem Graphics Inc. JediMind's Avatar
    Join Date
    Nov 2001
    Location
    Stockholm/Sweden
    Posts
    407

    Life Progressbar problem

    Hiya!

    I've done this a bunch of times before but now my brain just locked up and I can't figure it out.

    So I have a progress bar showing the players health.
    so you have 100 health and gets hit with damage 50, reducing your life to 50 or 50%. That I'd like to graphicly display with my health-bar.

    like a preloader you check if (framesLoaded==totalFrames)
    so I know this is a very simple formula and you guys should be able to crack it.

    my healthbar.scaleX should display the percentage left of my life graphicly
    How?
    Last edited by JediMind; 09-28-2010 at 11:45 AM. Reason: RESOLVED

  2. #2
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    healthbar.scaleX = 0.5 ?

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Just to be thorough, the percentage of life left is the current life level divided by the max life level.
    Code:
    healthbar.scaleX = health/maxHealth;

  4. #4
    MindGem Graphics Inc. JediMind's Avatar
    Join Date
    Nov 2001
    Location
    Stockholm/Sweden
    Posts
    407
    5tons.

    That's what I had from start and it just gave me all kinds of weird "progress scaling".
    But of course that's the very simple answer. It works now when I do the same

    Thanx!
    Resolved.

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