Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: RechargeableDoubleComponent

[21:7] extends: DoubleComponent

Wraps FXGL's RechargeableDoubleComponent (com.almasb.fxgl.dsl.components.RechargeableDoubleComponent), the abstract base for any rechargeable double-valued resource (HP, SP, ammo). Subclasses include HealthDoubleComponent and ManaDoubleComponent. This wrapper is abstract; construct one of the concrete subclasses, then optionally rewrap with adopt() if you want the base API.

Methods

  • RechargeableDoubleComponent ()

    Empty default constructor; populate with adopt().

  • adopt (object Ajo)

    Wraps an existing RechargeableDoubleComponent AussomJavaObject.

  • getValue ()

    Returns the current value (double).

  • setValue (double V)

    Sets the value. Internally clamped to [0..maxValue].

    • @p V is the new value.
    • @r this object
  • valueProperty ()

    Returns the DoubleProperty for value (binding-friendly).

  • getMaxValue ()

    Returns the max value (double).

  • setMaxValue (double V)

    Sets the max value. Current value is re-clamped if it exceeds the new max.

    • @p V is the new max value.
    • @r this object
  • maxValueProperty ()

    Returns the max-value DoubleProperty.

  • getValuePercent ()

    Returns the value as a percentage of max (0..100).

  • valuePercentProperty ()

    Returns the percent binding (value / max * 100).

  • damageFully ()

    Sets value to 0.

  • damage (double Amount)

    Reduces value by the given amount (clamped to 0).

    • @p Amount is the damage amount.
    • @r this object
  • damagePercentageCurrent (double Percentage)

    Damages by a percentage of current value.

    • @p Percentage is the percent of current value in 0..100.
    • @r this object
  • damagePercentageMax (double Percentage)

    Damages by a percentage of max value.

    • @p Percentage is the percent of max value in 0..100.
    • @r this object
  • restoreFully ()

    Restores value to max.

  • restore (double Amount)

    Restores by the given amount (clamped to max).

    • @p Amount is the restore amount.
    • @r this object
  • restorePercentageCurrent (double Percentage)

    Restores by a percentage of current value.

    • @p Percentage is the percent of current value in 0..100.
    • @r this object
  • restorePercentageMax (double Percentage)

    Restores by a percentage of max value.

    • @p Percentage is the percent of max value in 0..100.
    • @r this object
  • isZero ()

    True iff value is at or below zero.

  • zeroProperty ()

    Returns the BooleanBinding that fires true when value is 0.