How do I select and destroy HP bar of destroyed enemy2's

0 favourites
  • 4 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Although I'm familiar with Java and some other programming langugage, there are something that I can't get the idea how it is works in Construct 2. Most important one is selecting object. There is no refferences or specific names for objects. Most of them just created automatically and there is no way to find them later. (I couldn't find)

    I was following the first tutorial and I add sometingh to it. For example, there is a text that shows how many damage you create on monster. And I add a HP bar for monster. When a monster's HP is lower then or equal to 0 it is destroyed. But the HP bar of that enemy doesnt. You don't see the bar actually beacuse it's X and Y follows the enemys (monsters) X and Y's. When monster gone, HP bar is also gone. But it not destroyed. It is just doesn't showed. And at the end of game, all hp bars shown at the top left of the game. (This is the bug)

    I want to select these HP bars and destroy them with monsters. You can say it is not a big problem (actually it is because unused object should be deleted from memory) but I think in the future I will need to use this selection again and again. I want to learn how can I do it or Can I do it? Or should I do it or is there any other way?

  • hckarakurt depending on how you're managing the hp bar could be part of the monster's group(container) and it will be destroyed thatway, or you could be pinning it(using the pin behaviour) to the monster and set an event like when monster is destroyed unpin bar, and have another that says hpbarpinned(x) ->destroy or simply check if the bar value is lessthan or equal to 0 and destroy it... depending on what you used there's plenty of ways to achieve that goal.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Best way is to place healthbat in container with a monster so when monster dies all container items destroys too. To add hp bar to container select monster sprite and in properties find "Container"-"Create" and select HP bar. Also using this way will allow you to pick corresponding hp bar for the exact monster in events. And in "on create" monster sprite you can add parameters for hp bar at same event, corresponding hp bar will be picked, like pin it to monster sprite.

  • hckarakurt

    Check this screenshots they may lead to a clearer explanation. I'm using this method on a simple platformer im working on for fun.

    setting up the bar that is inside the container (which helps create one each time it spawns)

    im setting position and width and also pinning it to the object

    my destroy on unpin command

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