health bar for each enemy

0 favourites
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • Hello, mine is not working very well. THe HP Bars update wrong, somethings they are right other times not so much.

    It destroys the correct Frame, HEalth, and enemy. However sometimes it works correctly (2 enemies max) but when there are 3+ enemies you need to hit them all atleast 1 to update correctly, otherwise it updates the wrong health bar.

    Does this look right?

    (Creation)

    System Every 2.5 Seconds

    -Create FrameEnemy on layer Main 0,0

    -Create Dummy on layer Main Random(800,600)

    -Create BarEnemy on layer Main 0,0

    -Dummy set currentHealth to 5

    -Dummy set maxHealth to 5

    System Every Tick

    -FrameEnemy Set Position to (Dummy.X - 64, Dummy.Y - 48)

    -FrameEnemy Move to bottom of layer

    -BarEnemy Set Position to FrameEnemy (image point 0) <--- This was the problem. Should have been also Dummy.X - 64, Dummy.Y - 48 and not image point 0.

    -BarEnemy Set width to (Dummy.currentHealth * 125 (Width of image) / Dummy.maxHealth)

    -BarEnemy Move to Top of Layer

    Dummy CurrentHealth <

    System For Each Dummy

    -Dummy Destroy

    ->System Pick BarEnemy Instance 0

    -BarEnemy Destroy

    <font size="3">EDIT: SOLVED</font>

    ->System Pick FrameEnemy Instance 0

    -FrameEnemy Destroy

    Edit: For example look below:

    dl.dropbox.com/u/73299017/pixRPG/index.html

    <font size="3">EDIT: SOLVED</font>

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It seems to work when I remove FrameEnemy (the neat border around the health bar)

    If I get this working with the border, I will let you know.

    Edit: Okay I found out that it was because it was setting BarEnemy to imagepoint 0 of FrameEnemy (GUess it didn't know which Frame! Lol!) So I fixed it by setting both to go to Dummy.X - 64, Dummy.Y - 48

    Which btw is the height and width of the enemy sprite, which aligns the healthbar perfectly for me. (The imagepoint being not the center, but the most-left of the BarEnemy/FrameEnemy) (following the "Make a Fancy Healthar" tutorial, converting it for NPCs as well).

    Next step... to learn stability! Lol game starting to get a bit laggy now :/ Must need to do some organizing considering it is not my Laptop.

    ASUS G74-SX A-1

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)