@@ -3,6 +3,7 @@ package funkin.objects;
33import animate .FlxAnimate ;
44import animate .FlxAnimateFrames ;
55import flixel .animation .FlxAnimation ;
6+ import flixel .graphics .FlxGraphic ;
67import flixel .group .FlxSpriteGroup .FlxTypedSpriteGroup ;
78import flixel .util .FlxSignal .FlxTypedSignal ;
89import funkin .structures .ObjectStructure ;
@@ -30,31 +31,28 @@ class FunkinSprite extends FlxAnimate
3031 super (x , y );
3132 }
3233
33- override function initVars (): Void
34- {
35- super .initVars ();
36- }
37-
3834 /**
3935 * Loads or creates a texture and applies it to this sprite.
40- * @param path The asset path. (If `path` starts with a **#** then a color will be made instead and rectWidth + rectHeight will determine its size.)
41- * @param rectWidth If the path is a color then how big should it's width be?
42- * @param rectHeight If the path is a color then how big should it's height be?
36+ * @param path The asset path of the texture.
37+ * @param width What should the width of the sprite be?
38+ * @param height What should the height of the sprite be?
4339 * @return This `FunkinSprite` instance (nice for chaining stuff together, if you're into that).
4440 */
45- public function loadTexture (path : String = ' #000000' , rectWidth : Int = 1 , rectHeight : Int = 1 ): FunkinSprite
41+ public function loadTexture (path : String = ' #000000' , width : Int = 0 , height : Int = 0 ): FunkinSprite
4642 {
47- // Regex Check for colors?
48- if (path .startsWith (' #' ))
49- {
50- loadGraphic (FlxG .bitmap .create (1 , 1 , FlxColor .fromString (path ), false ));
51- scale .set (rectWidth , rectHeight );
52- updateHitbox ();
53- }
54- else
55- {
56- loadGraphic (Paths .content .imageGraphic (path ));
57- }
43+ var rectColor : Null <FlxColor > = FlxColor .fromString (path );
44+
45+ var graphic : FlxGraphic =
46+ {
47+ if (rectColor != null )
48+ FlxG .bitmap .create (1 , 1 , rectColor , false );
49+ else
50+ Paths .content .imageGraphic (path );
51+ }
52+
53+ loadGraphic (graphic );
54+ setGraphicSize (width , height );
55+ updateHitbox ();
5856
5957 return this ;
6058 }
0 commit comments