new StatusBarEndboss()
Represents a status bar that displays the health of a character or entity.
This class extends the DrawableObject class.
Extends
Classes
Members
height :number
The height of the drawable object.
Type:
- number
- Overrides:
- Source:
imageCache :Object.<string, HTMLImageElement>
A cache for storing images, with the image path as the key.
Type:
- Object.<string, HTMLImageElement>
- Inherited From:
- Source:
img :HTMLImageElement
The image used for the drawable object.
Type:
- HTMLImageElement
- Overrides:
- Source:
offset :Object
Offset values for adjusting collision detection or rendering.
Type:
- Object
- Inherited From:
- Source:
width :number
The width of the drawable object.
Type:
- number
- Overrides:
- Source:
x :number
The x-coordinate position of the drawable object.
Type:
- number
- Overrides:
- Source:
y :number
The y-coordinate position of the drawable object.
Type:
- number
- Overrides:
- Source:
(static) IMAGES :Array.<string>
An array of image paths representing different health levels.
Type:
- Array.<string>
(static) percentage :number
The current health percentage displayed on the status bar.
Type:
- number
Methods
draw(ctx)
Draws the current image on the provided canvas context.
Parameters:
| Name | Type | Description |
|---|---|---|
ctx |
CanvasRenderingContext2D | The drawing context of a canvas. |
- Inherited From:
- Source:
loadImage(path)
Loads a single image from the specified path.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path of the image to load. |
- Inherited From:
- Source:
loadImages(arr)
Loads multiple images and stores them in the image cache.
Parameters:
| Name | Type | Description |
|---|---|---|
arr |
Array.<string> | An array of image paths. |
- Inherited From:
- Source:
resolveImageIndex() → {number}
Determines the index of the image to display based on the current health percentage.
Returns:
The index corresponding to the current health level.
- Type
- number
setPercentage(percentage)
Sets the health percentage and updates the corresponding status bar image.
Parameters:
| Name | Type | Description |
|---|---|---|
percentage |
number | The new health percentage to display. |