From e978f5df7624781f2b179a9039110fe818e896ba Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 21 Sep 2024 16:32:44 -0400 Subject: [PATCH] fix for spirit's trail --- assets | 2 +- hmm.json | 4 +-- source/funkin/effects/FunkTrail.hx | 40 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 source/funkin/effects/FunkTrail.hx diff --git a/assets b/assets index 72bb24ac9..59546b1ac 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 72bb24ac9b0b9db4b2f9c38ef091e146ef16a1a4 +Subproject commit 59546b1ac78f591d1f7403b7a2209278bedfe63d diff --git a/hmm.json b/hmm.json index bbe4897b7..c6e3e7115 100644 --- a/hmm.json +++ b/hmm.json @@ -25,7 +25,7 @@ "name": "flixel-addons", "type": "git", "dir": null, - "ref": "9c6fb47968e894eb36bf10e94725cd7640c49281", + "ref": "e7789a32cf068eaa0abcaebc8dc07f6cf8f0632c", "url": "https://github.com/FunkinCrew/flixel-addons" }, { @@ -205,4 +205,4 @@ "url": "https://github.com/fponticelli/thx.semver" } ] -} +} \ No newline at end of file diff --git a/source/funkin/effects/FunkTrail.hx b/source/funkin/effects/FunkTrail.hx new file mode 100644 index 000000000..021a0e9b4 --- /dev/null +++ b/source/funkin/effects/FunkTrail.hx @@ -0,0 +1,40 @@ +package funkin.effects; + +import flixel.addons.effects.FlxTrail; +import funkin.play.stage.Bopper; +import flixel.FlxSprite; +import flixel.system.FlxAssets; + +/** + * An offshoot of FlxTrail, but accomodates the way Funkin + * does offsets for characters. example, fixes Spirits trail + */ +class FunkTrail extends FlxTrail +{ + /** + * Creates a new FunkTrail effect for a specific FlxSprite. + * + * @param Target The FlxSprite the trail is attached to. + * @param Graphic The image to use for the trailsprites. Optional, uses the sprite's graphic if null. + * @param Length The amount of trailsprites to create. + * @param Delay How often to update the trail. 0 updates every frame. + * @param Alpha The alpha value for the very first trailsprite. + * @param Diff How much lower the alpha of the next trailsprite is. + */ + public function new(Target:FlxSprite, ?Graphic:FlxGraphicAsset, Length:Int = 10, Delay:Int = 3, Alpha:Float = 0.4, Diff:Float = 0.05) + { + super(Target, Graphic, Length, Delay, Alpha, Diff); + } + + override public function updateTrail():Void + { + if (target is Bopper) + { + var targ:Bopper = cast target; + @:privateAccess effectOffset.set((targ.animOffsets[0] - targ.globalOffsets[0]) * targ.scale.x, + (targ.animOffsets[1] - targ.globalOffsets[1]) * targ.scale.y); + } + + super.updateTrail(); + } +}