-
Notifications
You must be signed in to change notification settings - Fork 4
/
NoteSplash.hx
65 lines (51 loc) · 1.93 KB
/
NoteSplash.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames;
class NoteSplash extends FlxSprite
{
public var colorSwap:ColorSwap = null;
private var idleAnim:String;
private var textureLoaded:String = null;
public function new(x:Float = 0, y:Float = 0, ?note:Int = 0) {
super(x, y);
var skin:String = 'noteSplashes';
if(PlayState.SONG.splashSkin != null && PlayState.SONG.splashSkin.length > 0) skin = PlayState.SONG.splashSkin;
loadAnims(skin);
colorSwap = new ColorSwap();
shader = colorSwap.shader;
setupNoteSplash(x, y, note);
antialiasing = ClientPrefs.globalAntialiasing;
}
public function setupNoteSplash(x:Float, y:Float, note:Int = 0, texture:String = null, hueColor:Float = 0, satColor:Float = 0, brtColor:Float = 0) {
setPosition(x - Note.swagWidth * 0.95, y - Note.swagWidth);
alpha = 0.6;
if(texture == null) {
texture = 'noteSplashes';
if(PlayState.SONG.splashSkin != null && PlayState.SONG.splashSkin.length > 0) texture = PlayState.SONG.splashSkin;
}
if(textureLoaded != texture) {
loadAnims(texture);
}
colorSwap.hue = hueColor;
colorSwap.saturation = satColor;
colorSwap.brightness = brtColor;
offset.set(10*(ClientPrefs.noteSize/0.7), 10*(ClientPrefs.noteSize/0.7));
var animNum:Int = FlxG.random.int(1, 2);
animation.play('note' + note + '-' + animNum, true);
animation.curAnim.frameRate = 24 + FlxG.random.int(-2, 2);
}
function loadAnims(skin:String) {
frames = Paths.getSparrowAtlas(skin);
for (i in 1...3) {
animation.addByPrefix("note1-" + i, "note splash blue " + i, 24, false);
animation.addByPrefix("note2-" + i, "note splash green " + i, 24, false);
animation.addByPrefix("note0-" + i, "note splash purple " + i, 24, false);
animation.addByPrefix("note3-" + i, "note splash red " + i, 24, false);
}
}
override function update(elapsed:Float) {
if(animation.curAnim.finished) kill();
super.update(elapsed);
}
}