-
Notifications
You must be signed in to change notification settings - Fork 0
/
BGSprite.hx
37 lines (33 loc) · 910 Bytes
/
BGSprite.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames;
class BGSprite extends FlxSprite
{
private var idleAnim:String;
public function new(image:String, x:Float = 0, y:Float = 0, ?scrollX:Float = 1, ?scrollY:Float = 1, ?animArray:Array<String> = null, ?loop:Bool = false) {
super(x, y);
if (animArray != null) {
frames = Paths.getSparrowAtlas(image);
for (i in 0...animArray.length) {
var anim:String = animArray[i];
animation.addByPrefix(anim, anim, 24, loop);
if(idleAnim == null) {
idleAnim = anim;
animation.play(anim);
}
}
} else {
if(image != null) {
loadGraphic(Paths.image(image));
}
active = false;
}
scrollFactor.set(scrollX, scrollY);
antialiasing = ClientPrefs.globalAntialiasing;
}
public function dance(?forceplay:Bool = false) {
if(idleAnim != null) {
animation.play(idleAnim, forceplay);
}
}
}