I need help with a little game I'm working on. I'm working on a basic life meter. Its just the same as we have seen forever. When you have all you life the bar is full as you loose life the bar goes down. I want the far left of the bar to be red and blended up to green. I've got the blending done and it looks great. I used a combination of the LinearGradientBrush and the Blend class to get the color right. Ive used a rectangle with the width being my %of life. So when i have 100 life the bar is full. When my life gets down to say 20 the bar is only 20 pixles wide.
Now my issue is that when you start to loose life the gradient percentages remain the same. When you have full life the bar is 20% red and 80% green. As i loose life those percentages remain the same. So instead of having the border between the red and green stay in the same position the border changes.
I imagine I can fix the issue by re calculating the gradient each time but it just seems like I shouldnt have to do that. I think if i coud have the gradient be pixel based not percentaged based it would work.
Any input would be greatly appreciated.
Thanks
Now my issue is that when you start to loose life the gradient percentages remain the same. When you have full life the bar is 20% red and 80% green. As i loose life those percentages remain the same. So instead of having the border between the red and green stay in the same position the border changes.
I imagine I can fix the issue by re calculating the gradient each time but it just seems like I shouldnt have to do that. I think if i coud have the gradient be pixel based not percentaged based it would work.
Any input would be greatly appreciated.
Thanks
Last edited: