class HealthIcon
package funkin.play.components
extends FunkinSprite
Available on all platforms
This is a rework of the health icon with the following changes: - The health icon now owns its own state logic. It queries health and updates the sprite itself, rather than relying on PlayState to command it. - The health icon now supports animations.
- The health icon will now search for a SparrowV2 (XML) spritesheet, and use that for rendering if it can.
- If it can't find a spritesheet, it will the old format; a two-frame 300x150 image.
-
If the spritesheet is found, the health icon will attempt to load and use the following animations as appropriate:
- `idle`, `winning`, `losing`, `toWinning`, `fromWinning`, `toLosing`, `fromLosing` - The health icon is now easier to control via scripts.
- Set
autoUpdateto false to prevent the health icon from changing its own animations. - Once
autoUpdateis false, you can manually callplayAnimation()to play a specific animation. - i.e.PlayState.instance.iconP1.playAnimation("losing") - Scripts can also utilize all functionality that a normal FlxSprite would have access to, such as adding supplimental animations.
- i.e.
PlayState.instance.iconP1.animation.addByPrefix("jumpscare", "jumpscare", 24, false);
Static variables
staticfinalread onlyHEALTH_ICON_SIZE:Int = 150
The size of a non-pixel icon when using the legacy format. Remember, modern icons can be any size.
Constructor
Variables
autoUpdate:Bool = true
Whether this health icon should automatically update its state based on the character's health. Note that turning this off means you have to manually do the following: - Boping the icon on the beat. - Switching between winning/losing/idle animations. - Repositioning the icon as health changes.
bopAngle:Float = 0.0
The amount, in degrees, to rotate the icon by when boping. ERIC NOTE: I experimented with this a bit but ended up turning it off, but why not leave it in for the script kiddies?
bopEvery:Int = Constants.STEPS_PER_BEAT
Apply the "bop" animation once every X steps. Defaults to once per beat.
characterId:String = Constants.DEFAULT_HEALTH_ICON
The character this icon is representing. Setting this variable will automatically update the graphic.
Methods
configure(data:Null<HealthIconData>):Void
Use the provided CharacterHealthIconData to configure this health icon's appearance.
Parameters:
data | The data to use to configure this health icon. |
|---|
playAnimation(name:String, ?fallback:String, restart:Bool = false):Void
Plays the animation with the given name.
Parameters:
name | The name of the animation to play. |
|---|---|
fallback | The fallback animation to play if the given animation is not found. |
restart | Whether to forcibly restart the animation if it is already playing. |
update(elapsed:Float):Void
Called by Flixel every frame. Includes logic to manage the currently playing animation.