@@ -45,7 +45,7 @@ enum CharType {
4545 OTHER ;
4646}
4747
48- class Character extends FunkinSprite
48+ class Character extends FlxSprite
4949{
5050 /**
5151 * In case a character is missing, it will use this on its place
@@ -91,13 +91,28 @@ class Character extends FunkinSprite
9191 public var invuln : Bool = false ;
9292 public var controlled : Bool = false ;
9393
94+ public var doubleGhosts : Array <FunkinSprite > = [];
95+ public var ghostID : Int = 0 ;
96+ public var ghostAnim : String = ' ' ;
97+ public var ghostTweenGRP : Array <FlxTween > = [];
98+
99+ public var mostRecentRow : Int = 0 ; // for ghost anims n shit
100+
94101 // This is literally only for the dropshadow shader
95102 public var charType : CharType = OTHER ;
96103
97104 public function new (x : Float , y : Float , ? character : String = ' bf' , ? isPlayer : Bool = false , ? chType : CharType = OTHER )
98105 {
99106 super (x , y );
100107
108+ for (i in 0 ... 4 ){
109+ var ghost = new FunkinSprite ();
110+ ghost .visible = false ;
111+ ghost .antialiasing = true ;
112+ ghost .alpha = 0.6 ;
113+ doubleGhosts .push (ghost );
114+ }
115+
101116 animation = new PsychAnimationController (this );
102117
103118 animOffsets = new Map <String , Array <Dynamic >>();
@@ -118,6 +133,7 @@ class Character extends FunkinSprite
118133
119134 public function changeCharacter (character : String )
120135 {
136+
121137 animationsArray = [];
122138 animOffsets = [];
123139 curCharacter = character ;
@@ -256,6 +272,8 @@ class Character extends FunkinSprite
256272
257273 if (debugMode || (! isAnimateAtlas && animation .curAnim == null ) || (isAnimateAtlas && (atlas .anim .curInstance == null || atlas .anim .curSymbol == null )))
258274 {
275+ for (ghost in doubleGhosts )
276+ ghost .update (elapsed );
259277 super .update (elapsed );
260278 return ;
261279 }
@@ -365,9 +383,8 @@ class Character extends FunkinSprite
365383
366384 return value ;
367385 }
368-
386+
369387 public var danced : Bool = false ;
370-
371388 /**
372389 * FOR GF DANCING SHIT
373390 */
@@ -477,6 +494,64 @@ class Character extends FunkinSprite
477494 animation .addByPrefix (name , anim , 24 , false );
478495 }
479496
497+ public function playGhostAnim (ghostID = 0 , AnimName : String , Force : Bool = false , Reversed : Bool = false , Frame : Int = 0 ) {
498+ try {
499+ var ghost : FlxSprite = doubleGhosts [ghostID ];
500+ ghost .scale .copyFrom (scale );
501+ ghost .frames = frames ;
502+ ghost .animation .copyFrom (animation );
503+ // ghost.shader = shader;
504+ ghost .x = x ;
505+ ghost .y = y ;
506+ ghost .flipX = flipX ;
507+ ghost .flipY = flipY ;
508+ ghost .alpha = alpha * 0.6 ;
509+ ghost .visible = true ;
510+ ghost .color = FlxColor .fromRGB (healthColorArray [0 ], healthColorArray [1 ], healthColorArray [2 ]);
511+ ghost .animation .play (AnimName , Force , Reversed , Frame );
512+ if (ghostTweenGRP [ghostID ] != null )
513+ ghostTweenGRP [ghostID ].cancel ();
514+
515+ var direction : String = AnimName .substring (4 );
516+
517+ var directionMap : Map <String , Array <Float >> = [
518+ ' UP' => [0 , - 45 ],
519+ ' DOWN' => [0 , 45 ],
520+ ' RIGHT' => [45 , 0 ],
521+ ' LEFT' => [- 45 , 0 ],
522+ ' UP-alt' => [0 , - 45 ],
523+ ' DOWN-alt' => [0 , 45 ],
524+ ' RIGHT-alt' => [45 , 0 ],
525+ ' LEFT-alt' => [- 45 , 0 ],
526+ ];
527+ // had to add alt cuz it kept crashing on room code LOL
528+
529+ var moveDirections : Array <Float > = [
530+ x + (directionMap .get (direction )[0 ]),
531+ y + (directionMap .get (direction )[1 ])
532+ ];
533+
534+ ghostTweenGRP [ghostID ] = FlxTween .tween (ghost , {alpha : 0 , x : moveDirections [0 ], y : moveDirections [1 ]}, 0.75 , {
535+ ease : FlxEase .linear ,
536+ onComplete : function (twn : FlxTween )
537+ {
538+ ghost .visible = false ;
539+ ghostTweenGRP [ghostID ].destroy (); // maybe?
540+ ghostTweenGRP [ghostID ] = null ;
541+ }
542+ });
543+
544+ var daOffset = animOffsets .get (AnimName );
545+ if (animOffsets .exists (AnimName ))
546+ ghost .offset .set (daOffset [0 ], daOffset [1 ]);
547+ else
548+ ghost .offset .set (0 , 0 );
549+ }
550+ catch (e ) {
551+ trace (' ERROR: $e ' );
552+ }
553+ }
554+
480555 // Atlas support
481556 // special thanks ne_eo for the references, you're the goat!!
482557 @:allow (states.editors. CharacterEditorState )
@@ -485,6 +560,11 @@ class Character extends FunkinSprite
485560 public var atlas : FlxAnimate ;
486561 public override function draw ()
487562 {
563+ for (ghost in doubleGhosts ){
564+ if (ghost .visible )
565+ ghost .draw ();
566+ }
567+
488568 var lastAlpha : Float = alpha ;
489569 var lastColor : FlxColor = color ;
490570 if (missingCharacter )
0 commit comments