Skip to content

Commit 49a4bd5

Browse files
Add extra info for Note Splashes
1 parent c696d07 commit 49a4bd5

3 files changed

Lines changed: 54 additions & 12 deletions

File tree

source/funkin/game/Splash.hx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package funkin.game;
2+
3+
class Splash extends FunkinSprite
4+
{
5+
/**
6+
* The current splash strum
7+
* WANRNING: It can be null
8+
*/
9+
public var strum:Null<Strum>;
10+
11+
/**
12+
* Shortcut to `strum.ID`
13+
* WARNING: It can be null
14+
*/
15+
public var strumID:Null<Int>;
16+
17+
public static function copyFrom(source:Splash):Splash
18+
{
19+
var spr = new Splash();
20+
@:privateAccess {
21+
spr.setPosition(source.x, source.y);
22+
spr.frames = source.frames;
23+
if (source.animateAtlas != null && source.atlasPath != null)
24+
spr.loadSprite(source.atlasPath);
25+
spr.animation.copyFrom(source.animation);
26+
spr.visible = source.visible;
27+
spr.alpha = source.alpha;
28+
spr.antialiasing = source.antialiasing;
29+
spr.scale.set(source.scale.x, source.scale.y);
30+
spr.scrollFactor.set(source.scrollFactor.x, source.scrollFactor.y);
31+
spr.skew.set(source.skew.x, source.skew.y);
32+
spr.transformMatrix = source.transformMatrix;
33+
spr.matrixExposed = source.matrixExposed;
34+
spr.zoomFactor = source.zoomFactor;
35+
spr.animOffsets = source.animOffsets.copy();
36+
}
37+
return spr;
38+
}
39+
}

source/funkin/game/SplashGroup.hx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package funkin.game;
22

33
import haxe.xml.Access;
44

5-
class SplashGroup extends FlxTypedGroup<FunkinSprite> {
5+
class SplashGroup extends FlxTypedGroup<Splash> {
66
/**
77
* Whenever the splash group has successfully loaded or not.
88
*/
@@ -46,7 +46,7 @@ class SplashGroup extends FlxTypedGroup<FunkinSprite> {
4646
}
4747

4848
function createSplash(imagePath:String) {
49-
var splash = new FunkinSprite();
49+
var splash = new Splash();
5050
splash.antialiasing = true;
5151
splash.active = splash.visible = false;
5252
splash.loadSprite(Paths.image(imagePath));
@@ -56,7 +56,7 @@ class SplashGroup extends FlxTypedGroup<FunkinSprite> {
5656
return splash;
5757
}
5858

59-
function setupAnims(xml:Access, splash:FunkinSprite) {
59+
function setupAnims(xml:Access, splash:Splash) {
6060
for(strum in xml.nodes.strum) {
6161
var id:Null<Int> = Std.parseInt(strum.att.id);
6262
if (id != null) {
@@ -80,18 +80,18 @@ class SplashGroup extends FlxTypedGroup<FunkinSprite> {
8080
a.push(anim.att.name);
8181
}
8282
}
83-
splash.animation.finishCallback = function(name:String) {
84-
splash.active = splash.visible = false;
85-
};
83+
splash.animation.finishCallback = (name:String) -> splash.active = splash.visible = false;
8684
}
8785

88-
function pregenerateSplashes(splash:FunkinSprite) {
86+
function pregenerateSplashes(splash:Splash) {
8987
// make 7 additional splashes
9088
for(i in 0...7) {
91-
var spr = FunkinSprite.copyFrom(splash);
92-
spr.animation.finishCallback = function(name:String) {
89+
var spr = Splash.copyFrom(splash);
90+
spr.animation.finishCallback = (name:String) -> {
9391
spr.active = spr.visible = false;
94-
};
92+
spr.strum = null;
93+
spr.strumID = null;
94+
}
9595
add(spr);
9696
}
9797
}
@@ -103,11 +103,14 @@ class SplashGroup extends FlxTypedGroup<FunkinSprite> {
103103
return animationNames[id][FlxG.random.int(0, animationNames[id].length - 1)];
104104
}
105105

106-
var __splash:FunkinSprite;
106+
var __splash:Splash;
107107
public function showOnStrum(strum:Strum) {
108108
if (!valid) return null;
109109
__splash = recycle();
110110

111+
__splash.strum = strum;
112+
__splash.strumID = strum.ID;
113+
111114
__splash.cameras = strum.lastDrawCameras;
112115
__splash.setPosition(strum.x + ((strum.width - __splash.width) / 2), strum.y + ((strum.height - __splash.height) / 2));
113116
__splash.active = __splash.visible = true;

source/funkin/game/SplashHandler.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package funkin.game;
22

33

4-
class SplashHandler extends FlxTypedGroup<FunkinSprite> {
4+
class SplashHandler extends FlxTypedGroup<Splash> {
55
/**
66
* Map containing all of the splashes group.
77
*/

0 commit comments

Comments
 (0)