new CoinBar()
- Source:
Extends
Members
IMAGES :Array.<string>
Array of image paths representing different fill levels of the coin bar.
Used to visually indicate how many coins the player has collected.
Type:
- Array.<string>
- Source:
height :number
Height of the status bar in pixels.
Type:
- number
- Inherited From:
- Source:
percentage :number
Current percentage value represented by the bar (0–100).
Determines which image is displayed.
Type:
- number
- Inherited From:
- Source:
width :number
Width of the status bar in pixels.
Type:
- number
- Inherited From:
- Source:
x :number
Horizontal position of the status bar on the screen.
Type:
- number
- Inherited From:
- Source:
y :number
Vertical position of the coin bar on the canvas.
Affects where the bar appears in the UI.
Type:
- number
- Source:
Methods
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: