From e3ed153a7ce43d0842f153676808422e4cf33fcd Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 29 Sep 2024 06:59:49 -0400 Subject: [PATCH 1/2] Add a "persist" argument to FunkinSound to prevent Results music from continuing in Freeplay. --- source/funkin/audio/FunkinSound.hx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index aa0b4b00a..98e0307ba 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -430,12 +430,13 @@ class FunkinSound extends FlxSound implements ICloneable * @param autoDestroy Whether to destroy this sound when it finishes playing. * Leave this value set to `false` if you want to re-use this `FunkinSound` instance. * @param autoPlay Whether to play the sound immediately or wait for a `play()` call. + * @param persist Whether to keep this `FunkinSound` between states, or destroy it. * @param onComplete Called when the sound finished playing. * @param onLoad Called when the sound finished loading. Called immediately for succesfully loaded embedded sounds. * @return A `FunkinSound` object, or `null` if the sound could not be loaded. */ public static function load(embeddedSound:FlxSoundAsset, volume:Float = 1.0, looped:Bool = false, autoDestroy:Bool = false, autoPlay:Bool = false, - ?onComplete:Void->Void, ?onLoad:Void->Void):Null + persist:Bool = false, ?onComplete:Void->Void, ?onLoad:Void->Void):Null { @:privateAccess if (SoundMixer.__soundChannels.length >= SoundMixer.MAX_ACTIVE_CHANNELS) @@ -462,7 +463,7 @@ class FunkinSound extends FlxSound implements ICloneable if (autoPlay) sound.play(); sound.volume = volume; sound.group = FlxG.sound.defaultSoundGroup; - sound.persist = true; + sound.persist = persist; // Make sure to add the sound to the list. // If it's already in, it won't get re-added. From 90f6f80a7176a2b67d27f922bdffac2af4ad5ef4 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 29 Sep 2024 07:06:11 -0400 Subject: [PATCH 2/2] Fix issues with animation offsets breaking on restart on characters with high offstes. --- source/funkin/play/character/BaseCharacter.hx | 8 +------- source/funkin/play/stage/Bopper.hx | 3 --- source/funkin/play/stage/Stage.hx | 7 +------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 365c8d112..1b5a68e96 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -233,15 +233,9 @@ class BaseCharacter extends Bopper */ public function resetCharacter(resetCamera:Bool = true):Void { - // Reset the animation offsets. This will modify x and y to be the absolute position of the character. - // this.animOffsets = [0, 0]; - - // Now we can set the x and y to be their original values without having to account for animOffsets. + // Set the x and y to be their original values. this.resetPosition(); - // Then reapply animOffsets... - // applyAnimationOffsets(getCurrentAnimation()); - this.dance(true); // Force to avoid the old animation playing with the wrong offset at the start of the song. // Make sure we are playing the idle animation // ...then update the hitbox so that this.width and this.height are correct. diff --git a/source/funkin/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx index 721a60517..4429e8d90 100644 --- a/source/funkin/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -150,11 +150,8 @@ class Bopper extends StageProp implements IPlayStateScriptedClass */ public function resetPosition() { - var oldAnimOffsets = [animOffsets[0], animOffsets[1]]; - animOffsets = [0, 0]; this.x = originalPosition.x; this.y = originalPosition.y; - animOffsets = oldAnimOffsets; } function update_shouldAlternate():Void diff --git a/source/funkin/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx index ad768769c..15648249c 100644 --- a/source/funkin/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -440,12 +440,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements character.x = stageCharData.position[0] - character.characterOrigin.x; character.y = stageCharData.position[1] - character.characterOrigin.y; - @:privateAccess(funkin.play.stage.Bopper) - { - // Undo animOffsets before saving original position. - character.originalPosition.x = character.x + character.animOffsets[0]; - character.originalPosition.y = character.y + character.animOffsets[1]; - } + character.originalPosition.set(character.x, character.y); var finalScale = character.getBaseScale() * stageCharData.scale; character.setScale(finalScale); // Don't use scale.set for characters!