Health bar percentage rise help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Martin84
    New Member
    • Jun 2007
    • 11

    Health bar percentage rise help needed

    Ok, for the game that I am creating at the moment I have a health bar animation that starts off full and empties as time goes on. When the health bar is empty it goes to the gameover screen. This part works fine.

    What I would like to happen is when the user runs into a target for the bar to increase by 10%, giving the user more time. The way it is set up at the moment the healthbar movieclip has the instance name "healthbar" .

    Inside this are 100 frames showing the bar going down (shape tween broken down into keyframes). 1 is the full healthbar, 0 is the empty healthbar.

    On the target I have the following code:

    //10 is the number of frames I would like to increase the bar by
    _root.healthbar += 10;

    However the bar just seems to keep going down. I think I need to find out the current frame the bar is at before adding 10 pixels to it but dont know how. Any help, can provide the .Fla if needed.

    Thanks,

    Martin
  • bergy
    New Member
    • Mar 2007
    • 89

    #2
    If you're using _root.healthbar += 10 exactly as you have typed that is your problem. "_root.healthba r" represents a MovieClip, so adding the Number 10 to the MovieClip isn't going to do anything.

    Try This:
    Code:
    _root.healthbar.gotoAndPlay(_root.healthbar._currentframe + 10);
    The above would be for ActionScript 2 (I'm assuming because of the depreciated _root keyword that's what you're coding in) - if you're using AS3 the equivalent is something like .currentFrame - I think.

    Edit: bleh for some reason in the code listing it's putting curre ntframe - with spaces in _currentframe. Make sure that's all one word if you copy and paste it.

    Comment

    Working...