drawSegmentBar function
-
Hey,
i created a drawSegmentBar function. You know those bars going from red to orange to green or vice versa.
The function allows you to define the position, width and height of the bar and you supply it the nr of segments to draw and your min max and current value to base the segment bar on. The function will then draw the segments as chosen and if your value changes the segments drawn or not drawn changes as well. You can create vertical or horizontal bars and flipped (right to left / bottom to top) or none flipped bars (left to right / top to bottom). you can also specify at which segments color changes need to happen. I'm no expert at this but it works for my usage and maybe people can use it or would like to experiment with it .I know i had some problems initially with itHere are some use cases:
- health bar
- mana bar
- speed meter (like MPH / KMH shown visually)
- Red / orange / green start racing light.
- displaying number of remaining lives or other things visually
- ...
Here's screenhot
from within my game:
different usages
Here's the functions codeHere's the share code
-
Very cool! I'll have that, thanks!
-
That is very nice! Thanks @joyrider3774 for sharing!