1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-09-20 09:09:00 +00:00
Funkin/source/funkin/freeplayStuff/DJBoyfriend.hx

59 lines
1.3 KiB
Haxe
Raw Normal View History

package funkin.freeplayStuff;
2021-10-21 19:05:32 +00:00
import flixel.FlxSprite;
2021-10-22 03:08:48 +00:00
import flixel.util.FlxSignal;
2021-10-21 19:05:32 +00:00
class DJBoyfriend extends FlxSprite
{
2021-10-22 03:08:48 +00:00
public var animHITsignal:FlxSignal;
2021-10-21 19:05:32 +00:00
public function new(x:Float, y:Float)
{
super(x, y);
2021-10-22 03:08:48 +00:00
animHITsignal = new FlxSignal();
2021-10-21 19:05:32 +00:00
animOffsets = new Map<String, Array<Dynamic>>();
frames = Paths.getSparrowAtlas('freeplay/bfFreeplay');
animation.addByPrefix('intro', "boyfriend dj intro", 24, false);
animation.addByPrefix('idle', "Boyfriend DJ0", 24);
animation.addByPrefix('confirm', "Boyfriend DJ confirm", 24);
addOffset('intro', 0, 0);
addOffset('idle', -4, -426);
2022-03-23 05:18:23 +00:00
playAnimation('intro');
2021-10-21 19:05:32 +00:00
animation.finishCallback = function(anim)
{
switch (anim)
{
case "intro":
2021-10-22 03:08:48 +00:00
animHITsignal.dispatch();
2022-03-23 05:18:23 +00:00
playAnimation('idle'); // plays idle anim after playing intro
2021-10-21 19:05:32 +00:00
}
};
}
// playAnim stolen from Character.hx, cuz im lazy lol!
public var animOffsets:Map<String, Array<Dynamic>>;
2022-03-23 05:18:23 +00:00
public function playAnimation(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void
2021-10-21 19:05:32 +00:00
{
animation.play(AnimName, Force, Reversed, Frame);
var daOffset = animOffsets.get(AnimName);
if (animOffsets.exists(AnimName))
{
offset.set(daOffset[0], daOffset[1]);
}
else
offset.set(0, 0);
}
public function addOffset(name:String, x:Float = 0, y:Float = 0)
{
animOffsets[name] = [x, y];
}
}