I'm having an issue with my healthbar

0 favourites
  • 4 posts
From the Asset Store
HealthBar
$19.99 USD
Advanced, customizable, visual bars to present amounts of points such health, mana, stamina and more
  • I'm using the healthbar system from Zelda here:

    scirra.com/arcade/example/320/zelda-style-lifebar

    Here is my .capx:

    dl.dropbox.com/u/91745263/WorkingTitle.capx

    If you compare the event parts between the two, they are correct.

    It is by far the most bizarre situation I have ever been in.

    I spent 6 hours trying to find what the issue is.

    So, if anyone of you masters out there find out the problem, please please tell me what's wrong.

    Here is what is known so far:

    The math seems to be working.

    The coins in the game can only be collected if you have less than full health.

    If you have full health, you cannot collect the coins.

    So, if you "flash"/get hurt two times, you can collect 2 coins, but can't collect a 3.

    So, the math seems to be right, it's just not changing the animation frame.

    I really appreciate it!

    PS: Switch to Level1 layout before running it

    PS: The fish and biohazard enemies will decrease life

  • Hmm, not sure why it doesn't work, looks pretty much the same to me.

    I would make sure that the first loop only runs once at the beginning of the layout. Seems to work fine if you add in an "On start of layout".

    I changed some other things as well, and deleted a bunch of stuff to make it smaller, but the events should be clear enough:

    EvanMCHealthBar.capx (r108.2)

  • When you destroy a sprite it doesn't get destroyed until the next top-level event. So the 'HealthBar' sprites destroyed in event 13 aren't really destroyed until event 20.

    What happens is:

    Event 13 flags the 5 HealthBar sprites to be destroyed and creates another 5 HealthBar sprites on top of them.

    Event 14 sets the animation frames correctly for the first 5 sprites which are going to be destroyed.

    At event 20 the 5 sprites are destroyed, leaving the 5 new sprites which haven't had their animation frames set.

    (Also in event 15 it should be playerLife/2 in the first condition)

    Nimtrix Creating the health sprites on start of layout wouldn't let you dynamically change the maxLife like in the arcade example. But if he doesn't need to do that then it would probably be better. Destroying and recreating the sprites every tick doesn't seem like a great idea.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ramones: Yeah, I suppose you're right. But you could just recreate the HealthBar objects every time you change maxLife, wouldn't be too difficult to handle imo.

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