icon code redo for more modularity

This commit is contained in:
Cameron Taylor 2021-03-18 21:08:44 -04:00
parent fd7a46a90a
commit 1af910c20e
17 changed files with 34 additions and 29 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

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)