Numbers Rollout

Discussion in 'Learning Javascript' started by Milena, Aug 5, 2016.

  1. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    I would like to ask if there's a simple way to rollout the numbers in the battle status when you take damage? Rollout meaning I want the numbers to slowly change instead of them going directly to the value my hp / mp currently is. So if I have 10 hp and I got hit by 6, the HP number slowly drops from 10 - 9 - 8 - 7 - 6 - 5 - 4?
     
    #1
  2. Resonance

    Resonance Veteran Veteran

    Messages:
    43
    Likes Received:
    6
    First Language:
    English
    Create another variable to keep track of "displayed hp".


    In your functions that draw the text/bars, make it compare the "real hp" vs "displayed hp". When there's a discrepancy between the two, increment "displayed hp" towards the "real hp", then draw the new "displayed hp".


    Now it'll just constantly draw new "displayed hp" values until it reaches the "real hp" value.
     
    #2
    McKathlin and Kino like this.
  3. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    It sounds like a possible idea, but wouldn't the oldHp variable something you can access inside the current drawn values? This means you have to get it inside drawActorHP itself. So it would just return the current HP rather than getting an old hp.
     
    #3
  4. Kino

    Kino EIS Game Dev Veteran

    Messages:
    515
    Likes Received:
    672
    Location:
    United States
    First Language:
    English
    Primarily Uses:
    RMMV
    One other option I think which is kind of like Earthbound, since they had hp that goes down slowly( this is if you don't want the actor to die immediately upon taking lots of damage).


    You would essentially want to not really change drawActorHp.


    Instead, when a character takes damage, you record that damage and subtract that damage from the actor hp over a certain amount of frames, until the recorded damage is 0.


    The other option mentioned above I think still requires that you check when the actor takes damage, and you store their hp before the hit takes place that would subtract from their health pool.


    I just checked and it seems BattleManager.invokeAction is where actions are invoked in battle; it takes a subject and a target parameter, so this might be a good place to make modifications or capture the hp information that you need.
     
    #4
    Milena likes this.
  5. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    I will try this right now, thank you.
     
    #5

Share This Page