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

Get help using Construct 2

Post » Fri Jan 13, 2017 1:41 pm

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?
B
3
Posts: 1
Reputation: 177

Post » Fri Jan 13, 2017 1:50 pm

@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.
Last edited by Ragevortex on Fri Jan 13, 2017 2:19 pm, edited 1 time in total.
Freefall Bird
B
47
S
9
G
5
Posts: 280
Reputation: 5,796

Post » Fri Jan 13, 2017 2:02 pm

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.
Creator of MiniDayZ
B
22
S
2
G
2
Posts: 75
Reputation: 1,858

Post » Fri Jan 13, 2017 3:08 pm

@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
Image

my destroy on unpin command
Image
Freefall Bird
B
47
S
9
G
5
Posts: 280
Reputation: 5,796


Return to How do I....?

Who is online

Users browsing this forum: divsyntax, pmerineau and 11 guests