Draw Instance Health Icon Draw Instance Health

With this action you can draw a coloured bar to show a graphic representation of the instance variable health (when you use any "health" action in GameMaker the instance that calls it will have a new instance scope variable called health added). The amount to be displayed is a percentage value that falls within the range of 0 - 100. You can set the direction anchor for drawing the healthbar (from left-to-right or right-to-left and top-to-bottom or bottom-to-top) as well as the position, either within the room or relative to the instance calling the action. You can also set the colour to be blended from each of the four corners of the healthbar, creating gradients from red to green (for example, but you can use any colours). Below you can see an image of how a simple healthbar looks with the different options:

Different Healthbar Settings

NOTE This action is only for use in the various Draw Events, and will not draw anything if used elsewhere.

 

 

Action Syntax:

Draw Instance Health Action

Arguments:

ArgumentDescription
DirectionThe direction to draw the healthbar contents
LeftThe position of the left side of the healthbar
TopThe position of the top of the healthbar
RightThe position of the right side of the healthbar
BottomThe position of the bottom of the healthbar
BackgroundThe colour to draw as the background on the healthbar
OutlineThe colour to use to outline the healthbar
Min ColourThe colour to blend from the minimum value
Max ColourThe colour to blend from the maximum value

 

Example:

Draw Instance Health ExampleThe above action block code draws a healthbar in the top left of the screen.