1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-30 16:56:47 +00:00
Funkin/source/funkin/ui/PixelatedIcon.hx

93 lines
2.4 KiB
Haxe
Raw Normal View History

2024-07-03 01:26:16 +00:00
package funkin.ui;
import flixel.FlxSprite;
2024-09-06 04:28:08 +00:00
import funkin.graphics.FlxFilteredSprite;
2024-07-03 01:26:16 +00:00
/**
* The icon that gets used for Freeplay capsules and char select
* NOT to be confused with the CharIcon class, which is for the in-game icons
*/
2024-09-06 04:28:08 +00:00
class PixelatedIcon extends FlxFilteredSprite
2024-07-03 01:26:16 +00:00
{
public function new(x:Float, y:Float)
{
super(x, y);
this.makeGraphic(32, 32, 0x00000000);
this.antialiasing = false;
this.active = false;
}
public function setCharacter(char:String):Void
{
var charPath:String = "freeplay/icons/";
switch (char)
{
2024-08-28 09:43:01 +00:00
case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf":
charPath += "bfpixel";
case "monster-christmas":
charPath += "monsterpixel";
case "mom" | "mom-car":
charPath += "mommypixel";
case "pico-blazin" | "pico-playable" | "pico-speaker":
charPath += "picopixel";
case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen":
charPath += "gfpixel";
case "dad":
charPath += "dadpixel";
case "darnell-blazin":
charPath += "darnellpixel";
case "senpai-angry":
charPath += "senpaipixel";
case "spooky-dark":
charPath += "spookypixel";
case "tankman-atlas":
charPath += "tankmanpixel";
2024-07-03 01:26:16 +00:00
default:
charPath += '${char}pixel';
}
if (!openfl.utils.Assets.exists(Paths.image(charPath)))
{
trace('[WARN] Character ${char} has no freeplay icon.');
return;
}
var isAnimated = openfl.utils.Assets.exists(Paths.file('images/$charPath.xml'));
if (isAnimated)
{
this.frames = Paths.getSparrowAtlas(charPath);
}
else
{
this.loadGraphic(Paths.image(charPath));
}
this.scale.x = this.scale.y = 2;
switch (char)
{
case 'parents-christmas':
this.origin.x = 140;
default:
this.origin.x = 100;
}
if (isAnimated)
{
this.active = true;
this.animation.addByPrefix('idle', 'idle0', 10, true);
this.animation.addByPrefix('confirm', 'confirm0', 10, false);
this.animation.addByPrefix('confirm-hold', 'confirm-hold0', 10, true);
this.animation.finishCallback = function(name:String):Void {
trace('Finish pixel animation: ${name}');
if (name == 'confirm') this.animation.play('confirm-hold');
};
this.animation.play('idle');
}
}
}