Class: StatusBar

StatusBar()

Represents a status bar showing the health of a character or entity, extending the DrawableObject class.

Constructor

new StatusBar()

Constructs the StatusBar, loads its images, sets its initial position, size, and initializes the health percentage to 100.
Source:

Members

IMAGES :Array.<string>

An array of image paths representing different health levels.
Type:
  • Array.<string>
Source:

percentage :number

The current health percentage displayed by the status bar.
Type:
  • number
Source:

Methods

resolveImageIndex() → {number}

Determines the index of the correct image in the IMAGES array based on the current health percentage.
Source:
Returns:
- The index corresponding to the current health level.
Type
number

setPercentage(percentage)

Sets the health percentage and updates the status bar image accordingly.
Parameters:
Name Type Description
percentage number The new health percentage to display.
Source: