Individual Unit Health Bars

For questions about using Classic.

Post » Tue Nov 24, 2009 4:07 am

I have been trying to wrap my brain around this one for an RTS style game.

I have considered some different options and all really not making much sense to me so I figured
I would throw my ideas at you wrong as they may be.

Hopefully some better ideas come out and give me a good point to start at.

Idea #1 (really not what I hope to do) Draw the green health bar above my unit sprite's but
have 100 frames and then use code to determine what % of 100 of the units total hps are at
any given time then simply have that display that frame of the animation. The reason this is
such a terrible idea is because once I go from stationary sprites to sprites with a full movement
of animation I would need such a huge amount of 100 frames per frame of animation that it makes
my head hurt.

Idea #2 Create a healthbar type of sprite and somehow have it follow my individual unit -- use the 100 frame animation for it based off of the percentage of total hps like my previous idea. This might be going about it at an incredibly non optimal way but it *would* work -- but my problem next would be having that sprite work for each individual unit? Or would changing the animation for it change it for all of the copies of the healthbar sprite. I could evolve the idea to create as many health bars as allowable units in the game so that they all have their individual health bar need in accordance to the unit that spawned by maybe using variables.

I know someone is prob gonna post .. "bro wow, no... just simply do this and BAM done" and if someone does post that, great!

Any suggestions would be very helpful, thank you.
Posts: 16
Reputation: 907

Post » Tue Nov 24, 2009 6:43 am

bro wow, no... just simply use two sprites in a container with the unit, moving them every frame to a position relative to that unit: bar background and bar progress, set the hotspot to the left side and set the width of the bar progress sprite to originalsize*(health/maxhealth)and BAM done
Posts: 1,445
Reputation: 4,665

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests