1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-23 15:26:06 +00:00

icon code redo for more modularity

This commit is contained in:
Cameron Taylor 2021-03-18 21:08:44 -04:00
parent 99407f07ab
commit fdd8e0445e
2 changed files with 34 additions and 29 deletions

View file

@ -2,6 +2,8 @@ package;
import flixel.FlxSprite;
using StringTools;
class HealthIcon extends FlxSprite
{
/**
@ -9,37 +11,45 @@ class HealthIcon extends FlxSprite
*/
public var sprTracker:FlxSprite;
var char:String = 'bf';
var isPlayer:Bool = false;
public function new(char:String = 'bf', isPlayer:Bool = false)
{
super();
loadGraphic(Paths.image('iconGrid'), true, 150, 150);
this.isPlayer = isPlayer;
this.char = char;
loadIcon(char);
antialiasing = true;
animation.add('bf', [0, 1], 0, false, isPlayer);
animation.add('bf-holding-gf', [0, 1], 0, false, isPlayer);
animation.add('bf-car', [0, 1], 0, false, isPlayer);
animation.add('bf-christmas', [0, 1], 0, false, isPlayer);
animation.add('bf-pixel', [21, 21], 0, false, isPlayer);
animation.add('spooky', [2, 3], 0, false, isPlayer);
animation.add('pico', [4, 5], 0, false, isPlayer);
animation.add('pico-speaker', [4, 5], 0, false, isPlayer);
animation.add('mom', [6, 7], 0, false, isPlayer);
animation.add('mom-car', [6, 7], 0, false, isPlayer);
animation.add('tankman', [8, 9], 0, false, isPlayer);
animation.add('face', [10, 11], 0, false, isPlayer);
animation.add('dad', [12, 13], 0, false, isPlayer);
animation.add('senpai', [22, 22], 0, false, isPlayer);
animation.add('senpai-angry', [22, 22], 0, false, isPlayer);
animation.add('spirit', [23, 23], 0, false, isPlayer);
animation.add('bf-old', [14, 15], 0, false, isPlayer);
animation.add('gf', [16], 0, false, isPlayer);
animation.add('parents-christmas', [17], 0, false, isPlayer);
animation.add('monster', [19, 20], 0, false, isPlayer);
animation.add('monster-christmas', [19, 20], 0, false, isPlayer);
animation.play(char);
scrollFactor.set();
}
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
{
var realChar:String = char.split('-')[0].trim();
loadGraphic(Paths.image('icons/icon-' + realChar), true, 150, 150);
animation.add(realChar, [0, 1], 0, false, isPlayer);
animation.play(realChar);
}
override function update(elapsed:Float)
{
super.update(elapsed);

View file

@ -1389,12 +1389,7 @@ class PlayState extends MusicBeatState
#end
if (FlxG.keys.justPressed.NINE)
{
if (iconP1.animation.curAnim.name == 'bf-old')
iconP1.animation.play(SONG.player1);
else
iconP1.animation.play('bf-old');
}
iconP1.swapOldIcon();
// do this BEFORE super.update() so songPosition is accurate
if (startingSong)