mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-29 08:16:58 +00:00
daef9e0759
also changes to HealthIcon to better work in ChartingState
65 lines
1.2 KiB
Haxe
65 lines
1.2 KiB
Haxe
package;
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
using StringTools;
|
|
|
|
class HealthIcon extends FlxSprite
|
|
{
|
|
/**
|
|
* Used for FreeplayState! If you use it elsewhere, prob gonna annoying
|
|
*/
|
|
public var sprTracker:FlxSprite;
|
|
|
|
var char:String = '';
|
|
var isPlayer:Bool = false;
|
|
|
|
public function new(char:String = 'bf', isPlayer:Bool = false)
|
|
{
|
|
super();
|
|
|
|
this.isPlayer = isPlayer;
|
|
|
|
changeIcon(char);
|
|
antialiasing = true;
|
|
scrollFactor.set();
|
|
}
|
|
|
|
public var isOldIcon:Bool = false;
|
|
|
|
public function swapOldIcon():Void
|
|
{
|
|
isOldIcon = !isOldIcon;
|
|
|
|
if (isOldIcon)
|
|
changeIcon('bf-old');
|
|
else
|
|
changeIcon('bf');
|
|
}
|
|
|
|
public function changeIcon(newChar:String):Void
|
|
{
|
|
if (newChar != 'bf-pixel' && newChar != 'bf-old')
|
|
newChar = newChar.split('-')[0].trim();
|
|
|
|
if (newChar != char)
|
|
{
|
|
if (animation.getByName(newChar) == null)
|
|
{
|
|
loadGraphic(Paths.image('icons/icon-' + newChar), true, 150, 150);
|
|
animation.add(newChar, [0, 1], 0, false, isPlayer);
|
|
}
|
|
animation.play(newChar);
|
|
char = newChar;
|
|
}
|
|
}
|
|
|
|
override function update(elapsed:Float)
|
|
{
|
|
super.update(elapsed);
|
|
|
|
if (sprTracker != null)
|
|
setPosition(sprTracker.x + sprTracker.width + 10, sprTracker.y - 30);
|
|
}
|
|
}
|