Skip to content

ChargeBar

class ChargeBar(
healthBar: HealthBarDefinition,
currentPercentage: Int = 100,
animationSpeed: Int = 0
) : OverheadBar(healthBar = healthBar, currentPercentage = currentPercentage, animationSpeed = animationSpeed)
Example
fun charge(player: Actor, bar: HealthBarDefinition, percent: Int) {
val charge = player.findComponent<ChargeBar>() ?: ChargeBar(bar, currentPercentage = 0).also { player.addComponent(it) }
charge.currentPercentage = percent
if (percent >= 100) player.message("Your special attack is ready.")
}