A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Stats bars

  1. #1
    Member
    Join Date
    Apr 2011
    Posts
    42

    Stats bars

    Hey guys,

    I'm currently working on a sniper rifle game, well the menu and stats screen at the moment and have 4 stats bars for each rifle (range, recoil, mag size and mobility) will be 5 soon when added rate of fire. Each rifle has different stats and the range bar (for example) will be different widths for each rifle. If I wanted the scope add on 100 pixels of width to the range bar no matter what size it currently is how do I go about it?

  2. #2
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    Use the Games forum's search to find an answer. Search for "stat bar", "life bar", "power bar", etc. Discusssed many many many times already.

  3. #3
    Member
    Join Date
    Apr 2011
    Posts
    42
    Already had a look but didn't see what code I'm looking for. Searching on my mobile as just moved house and sky have quoted me a month to get broadband back up.

  4. #4
    Member
    Join Date
    Apr 2011
    Posts
    42
    Already had a look but didn't see what code I'm looking for. Searching on my mobile as just moved house and sky have quoted me a month to get broadband back up.

  5. #5
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    I don't really understand your question, maybe a picture would help. I'll try to explain.

    Think of the concept as basic algebra. You have your current stat and your maximum stat. Just make that into a percentage.

    Actionscript Code:
    var perc:Number = (currentStat/maximumStat);

    Then you can multiply that percentage with the width or use that percentage to choose a frame.

    Actionscript Code:
    var barMaxWidth:Number = 300;

    bar1.width = barMaxWidth * perc

    or

    Actionscript Code:
    bar1.gotoAndStop( bar1.totalFrames * perc);

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