2020-12-24 18:24:11 -05:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
|
2021-03-18 21:08:44 -04:00
|
|
|
using StringTools;
|
|
|
|
|
2020-12-24 18:24:11 -05:00
|
|
|
class HealthIcon extends FlxSprite
|
|
|
|
{
|
2021-03-01 18:59:51 -05:00
|
|
|
/**
|
|
|
|
* Used for FreeplayState! If you use it elsewhere, prob gonna annoying
|
|
|
|
*/
|
|
|
|
public var sprTracker:FlxSprite;
|
|
|
|
|
2021-03-18 21:08:44 -04:00
|
|
|
var char:String = 'bf';
|
|
|
|
var isPlayer:Bool = false;
|
|
|
|
|
2020-12-24 18:24:11 -05:00
|
|
|
public function new(char:String = 'bf', isPlayer:Bool = false)
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2021-03-18 21:08:44 -04:00
|
|
|
this.isPlayer = isPlayer;
|
|
|
|
this.char = char;
|
|
|
|
|
|
|
|
loadIcon(char);
|
2020-12-24 18:24:11 -05:00
|
|
|
antialiasing = true;
|
|
|
|
scrollFactor.set();
|
|
|
|
}
|
2021-03-01 18:59:51 -05:00
|
|
|
|
2021-03-18 21:08:44 -04:00
|
|
|
public var isOldIcon:Bool = false;
|
|
|
|
|
|
|
|
public function swapOldIcon():Void
|
|
|
|
{
|
|
|
|
isOldIcon = !isOldIcon;
|
|
|
|
|
|
|
|
if (isOldIcon)
|
|
|
|
{
|
|
|
|
loadGraphic(Paths.image('icons/icon-bf-old'), true, 150, 150);
|
|
|
|
animation.add('bf-old', [0, 1], 0, false, isPlayer);
|
|
|
|
animation.play('bf-old');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
loadIcon(char);
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadIcon(char:String):Void
|
|
|
|
{
|
2021-03-19 00:03:29 -04:00
|
|
|
var realChar:String = "";
|
|
|
|
switch (char)
|
|
|
|
{
|
|
|
|
case 'bf-pixel':
|
|
|
|
realChar = char;
|
|
|
|
default:
|
|
|
|
realChar = char.split('-')[0].trim();
|
|
|
|
}
|
|
|
|
|
2021-03-18 21:08:44 -04:00
|
|
|
loadGraphic(Paths.image('icons/icon-' + realChar), true, 150, 150);
|
|
|
|
animation.add(realChar, [0, 1], 0, false, isPlayer);
|
|
|
|
animation.play(realChar);
|
|
|
|
}
|
|
|
|
|
2021-03-01 18:59:51 -05:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
if (sprTracker != null)
|
|
|
|
setPosition(sprTracker.x + sprTracker.width + 10, sprTracker.y - 30);
|
|
|
|
}
|
2020-12-24 18:24:11 -05:00
|
|
|
}
|