@@ -72,24 +72,34 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
72
72
moves = false ;
73
73
}
74
74
75
- public static function copyFrom (source : FunkinSprite )
75
+ /**
76
+ * Gets the graphics and copies other properties from another sprite (Works both for `FlxSprite` and `FunkinSprite`!).
77
+ */
78
+ public static function copyFrom (source : FlxSprite ): FunkinSprite
76
79
{
77
80
var spr = new FunkinSprite ();
81
+ var casted : FunkinSprite = null ;
82
+ if (source is FunkinSprite )
83
+ casted = cast source ;
84
+
78
85
@:privateAccess {
79
86
spr .setPosition (source .x , source .y );
80
87
spr .frames = source .frames ;
81
- if (source .animateAtlas != null && source .atlasPath != null )
82
- spr .loadSprite (source .atlasPath );
88
+ if (casted != null && casted .animateAtlas != null && casted .atlasPath != null )
89
+ spr .loadSprite (casted .atlasPath );
83
90
spr .animation .copyFrom (source .animation );
84
91
spr .visible = source .visible ;
85
92
spr .alpha = source .alpha ;
86
93
spr .antialiasing = source .antialiasing ;
87
94
spr .scale .set (source .scale .x , source .scale .y );
88
95
spr .scrollFactor .set (source .scrollFactor .x , source .scrollFactor .y );
89
- spr .skew .set (source .skew .x , source .skew .y );
90
- spr .transformMatrix = source .transformMatrix ;
91
- spr .matrixExposed = source .matrixExposed ;
92
- spr .animOffsets = source .animOffsets .copy ();
96
+
97
+ if (casted != null ) {
98
+ spr .skew .set (casted .skew .x , casted .skew .y );
99
+ spr .transformMatrix = casted .transformMatrix ;
100
+ spr .matrixExposed = casted .matrixExposed ;
101
+ spr .animOffsets = casted .animOffsets .copy ();
102
+ }
93
103
}
94
104
return spr ;
95
105
}
0 commit comments