3 Replies Latest reply on Mar 31, 2016 6:24 PM by kglad

    How to decrease HP incrementally instead of instantly?

    Khalan Level 1



      I'm currently having an issue where if I decrease the HP using hpBar - 100 or w/e it decreases instantly.

      Is there a way to get it to run down incrementally by 1s? For example:

      HP = 100


      If I do hp - 10, it'll go from 100 to 99, 99 to 98, etc until it reaches 90?


      EDIT: For further clarification, my code snippet:

      Once the button has been clicked on it'll run something like this:


      dmgRandomizer = random(1000);

      storeHeroDmg = _root.enemyHP - _root.dmgRandomizer;


      while (_root.enemyHP != _root.storeHeroDmg)


           enemyHP = _root.enemyHP - 1;



      But this still decreases the HP instantly instead of gradually.

      I've been trying a few other tricks but my limited knowledge has been exhausted and I'm out of ideas.