new EndbossHealthBar()
- Source:
Extends
Members
boss :MovableObject
Reference to the Endboss object for dynamic position or health syncing.
Type:
height :number
Height of the health bar in pixels.
Type:
- number
- Overrides:
- Source:
percentage :number
Current fill level of the health bar (0–100).
Represents the Endboss's remaining health.
Type:
- number
- Overrides:
- Source:
width :number
Width of the health bar in pixels.
Affects its size on the screen.
Type:
- number
- Overrides:
- Source:
x :number
Horizontal position of the health bar, aligned with the Endboss.
Type:
- number
- Overrides:
- Source:
y :number
Vertical position of the health bar, placed above the Endboss.
Type:
- number
Methods
animate()
Starts the animation loop for the health bar.
Uses requestAnimationFrame for smooth rendering and optimal performance.
resolveImageIndex() → {number}
Resolves the image index based on the current percentage value.
Used to determine which visual state of the bar to display.
- Inherited From:
- Source:
Returns:
Index of the image corresponding to the percentage.
- Type
- number
setPercentage(percentage)
Updates the current percentage and sets the corresponding image.
The image is chosen based on the percentage value using resolveImageIndex().
Parameters:
Name | Type | Description |
---|---|---|
percentage |
number | The new percentage value (0–100). |
- Inherited From:
- Source:
stickToBoss()
Updates the position of the health bar relative to the Endboss.
Positions the bar centered horizontally and slightly above the boss.