Skip to content

Commit 7daa7a5

Browse files
authored
Add extra info for Note Splashes (#558)
* add extra info for splashes * nullable * moved SplashHandler.__copyFrom to Splash.copyFrom
1 parent f989a1b commit 7daa7a5

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

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: 11 additions & 6 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) {
@@ -85,12 +85,14 @@ class SplashGroup extends FlxTypedGroup<FunkinSprite> {
8585
};
8686
}
8787

88-
function pregenerateSplashes(splash:FunkinSprite) {
88+
function pregenerateSplashes(splash:Splash) {
8989
// make 7 additional splashes
9090
for(i in 0...7) {
91-
var spr = FunkinSprite.copyFrom(splash);
91+
var spr = Splash.copyFrom(splash);
9292
spr.animation.finishCallback = function(name:String) {
9393
spr.active = spr.visible = false;
94+
spr.strum = null;
95+
spr.strumID = null;
9496
};
9597
add(spr);
9698
}
@@ -103,11 +105,14 @@ class SplashGroup extends FlxTypedGroup<FunkinSprite> {
103105
return animationNames[id][FlxG.random.int(0, animationNames[id].length - 1)];
104106
}
105107

106-
var __splash:FunkinSprite;
108+
var __splash:Splash;
107109
public function showOnStrum(strum:Strum) {
108110
if (!valid) return null;
109111
__splash = recycle();
110112

113+
__splash.strum = strum;
114+
__splash.strumID = strum.ID;
115+
111116
__splash.cameras = strum.lastDrawCameras;
112117
__splash.setPosition(strum.x + ((strum.width - __splash.width) / 2), strum.y + ((strum.height - __splash.height) / 2));
113118
__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)