2021-03-07 15:34:21 -05:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
|
|
|
|
class BGSprite extends FlxSprite
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
Cool lil utility thing just so that it can easy do antialiasing and scrollfactor bullshit
|
|
|
|
*/
|
2021-03-08 18:38:58 -05:00
|
|
|
public var idleAnim:String;
|
|
|
|
|
2021-08-28 12:41:15 -04:00
|
|
|
/**
|
|
|
|
* NOTE: loadOldWay param is just for current backward compatibility! Will be moved later!
|
|
|
|
*/
|
|
|
|
public function new(image:String, x:Float = 0, y:Float = 0, parX:Float = 1, parY:Float = 1, ?daAnimations:Array<String>, ?loopingAnim:Bool = false,
|
|
|
|
?loadOldWay:Bool = true)
|
2021-03-07 15:34:21 -05:00
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
2021-08-28 12:41:15 -04:00
|
|
|
if (loadOldWay)
|
2021-03-08 18:38:58 -05:00
|
|
|
{
|
2021-08-28 12:41:15 -04:00
|
|
|
if (daAnimations != null)
|
2021-03-08 18:38:58 -05:00
|
|
|
{
|
2021-08-28 12:41:15 -04:00
|
|
|
setupSparrow(image, daAnimations, loopingAnim);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
justLoadImage(image);
|
2021-03-08 18:38:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-07 15:34:21 -05:00
|
|
|
scrollFactor.set(parX, parY);
|
|
|
|
antialiasing = true;
|
2021-03-08 18:38:58 -05:00
|
|
|
}
|
|
|
|
|
2021-08-28 12:41:15 -04:00
|
|
|
public function setupSparrow(image:String, daAnimations:Array<String>, ?loopingAnim:Bool = false)
|
|
|
|
{
|
|
|
|
frames = Paths.getSparrowAtlas(image);
|
|
|
|
for (anims in daAnimations)
|
|
|
|
{
|
|
|
|
var daLoop:Bool = loopingAnim;
|
|
|
|
if (loopingAnim == null)
|
|
|
|
daLoop = false;
|
|
|
|
|
|
|
|
animation.addByPrefix(anims, anims, 24, daLoop);
|
|
|
|
animation.play(anims);
|
|
|
|
|
|
|
|
if (idleAnim == null)
|
|
|
|
idleAnim = anims;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function justLoadImage(image:String)
|
|
|
|
{
|
|
|
|
loadGraphic(Paths.image(image));
|
|
|
|
active = false;
|
|
|
|
}
|
|
|
|
|
2021-03-08 18:38:58 -05:00
|
|
|
public function dance():Void
|
|
|
|
{
|
|
|
|
if (idleAnim != null)
|
|
|
|
animation.play(idleAnim);
|
2021-03-07 15:34:21 -05:00
|
|
|
}
|
|
|
|
}
|