Tobee_Night_Funkin_PSYCH/source/AttachedSprite.hx

52 lines
1.1 KiB
Haxe
Raw Normal View History

2021-11-05 21:34:27 +00:00
package;
import flixel.FlxSprite;
using StringTools;
class AttachedSprite extends FlxSprite
{
public var sprTracker:FlxSprite;
public var xAdd:Float = 0;
public var yAdd:Float = 0;
public var angleAdd:Float = 0;
public var alphaAdd:Float = 0;
public var copyAngle:Bool = true;
public var copyAlpha:Bool = true;
public var copyVisible:Bool = false;
public function new(file:String, ?anim:String = null, ?library:String = null, ?loop:Bool = false)
{
super();
if(anim != null) {
frames = Paths.getSparrowAtlas(file, library);
animation.addByPrefix('idle', anim, 24, loop);
animation.play('idle');
} else {
loadGraphic(Paths.image(file));
}
antialiasing = ClientPrefs.globalAntialiasing;
scrollFactor.set();
}
override function update(elapsed:Float)
{
super.update(elapsed);
if (sprTracker != null) {
setPosition(sprTracker.x + xAdd, sprTracker.y + yAdd);
scrollFactor.set(sprTracker.scrollFactor.x, sprTracker.scrollFactor.y);
if(copyAngle)
angle = sprTracker.angle + angleAdd;
if(copyAlpha)
alpha = sprTracker.alpha + alphaAdd;
if(copyVisible)
visible = sprTracker.visible;
}
}
}