Deteriorating Health

Get help using Construct 2

Post » Sat Nov 02, 2013 6:45 pm

How do I script a health bar that is constantly deteriorating unless the player is in a certain zone?
Posts: 1
Reputation: 177

Post » Sat Nov 02, 2013 8:28 pm

Well, this should be easy:
1. Add a private variable to your player - health.
2. Create an even with the condition - "is player overlapping safe zone".
3. Right click on the condition, press invert.
4. Add a "substract x from" action to the event.
5. (optional) add an every x seconds to your event, for timing purposes

Was that so hard?
Kids in my day used to read the manual or watch the videos on Youtube,
or at least think for themselves (i am yet to see someone ask more basic questions, sorry,
i just feel that there is a lot of unnecessary content here - spam). Also, GET OFF MY LAWN!

If you meant an actual health bar:
1. Make a 9-patch image with your health bar, set up as needed.
2. Set the left side as a hotspot.
3. Create an "every tick/x seconds" event.
4. Add "set 9-patch width to*SomeRandomAmount" to it.Stiivais2013-11-02 20:32:39
Posts: 163
Reputation: 1,436

Post » Sun Nov 03, 2013 3:42 pm

If I remember correctly, the 9 Patch is one of the worst performing plugins you could use, and isn't really necessary for a life bar. You could just use a Sprite object filled with a color. For example, I have a red Sprite object drawn out to the width I want it to be, then a Green Sprite that lies on top of it, and it's width is determined by the player character's health (instance variable). Every tick, evaluate the player character health instance variable, and adjust the width of the green Sprite appropriately. It'd be better performance wise than the 9 Patch...

I believe there's a tutorial here for this very thing.
Posts: 143
Reputation: 1,795

Return to How do I....?

Who is online

Users browsing this forum: Fenix18, Google [Bot] and 62 guests