mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-26 17:46:08 -05:00
Replace calls to FlxG.sound.playMusic with ones that set the BPM.
This commit is contained in:
parent
ecea5e89e2
commit
24b03e4f6b
6 changed files with 51 additions and 27 deletions
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit 024ade791ffc39afcf8b075841b19ca0f67b00d5
|
||||
Subproject commit 3e8bea70e7dcc76df67a0e87b85ef28ed5140371
|
|
@ -290,10 +290,11 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
|
|||
* @param key The key of the music you want to play. Music should be at `music/<key>/<key>.ogg`.
|
||||
* @param params A set of additional optional parameters.
|
||||
* Data should be at `music/<key>/<key>-metadata.json`.
|
||||
* @return Whether the music was started. `false` if music was already playing or could not be started
|
||||
*/
|
||||
public static function playMusic(key:String, params:FunkinSoundPlayMusicParams):Void
|
||||
public static function playMusic(key:String, params:FunkinSoundPlayMusicParams):Bool
|
||||
{
|
||||
if (!(params.overrideExisting ?? false) && (FlxG.sound.music?.exists ?? false) && FlxG.sound.music.playing) return;
|
||||
if (!(params.overrideExisting ?? false) && (FlxG.sound.music?.exists ?? false) && FlxG.sound.music.playing) return false;
|
||||
|
||||
if (!(params.restartTrack ?? false) && FlxG.sound.music?.playing)
|
||||
{
|
||||
|
@ -303,7 +304,7 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
|
|||
// Stop here if we would play a matching music track.
|
||||
if (existingSound._label == Paths.music('$key/$key'))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,11 +329,20 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
|
|||
FlxG.sound.music.kill();
|
||||
}
|
||||
|
||||
var music = FunkinSound.load(Paths.music('$key/$key'), params?.startingVolume ?? 1.0, true, false, true);
|
||||
if (music != null) FlxG.sound.music = music;
|
||||
var music = FunkinSound.load(Paths.music('$key/$key'), params?.startingVolume ?? 1.0, params.loop ?? true, false, true);
|
||||
if (music != null)
|
||||
{
|
||||
FlxG.sound.music = music;
|
||||
|
||||
// Prevent repeat update() and onFocus() calls.
|
||||
FlxG.sound.list.remove(FlxG.sound.music);
|
||||
// Prevent repeat update() and onFocus() calls.
|
||||
FlxG.sound.list.remove(FlxG.sound.music);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -451,6 +461,12 @@ typedef FunkinSoundPlayMusicParams =
|
|||
*/
|
||||
var ?restartTrack:Bool;
|
||||
|
||||
/**
|
||||
* Whether the music should loop or play once.
|
||||
* @default `true`
|
||||
*/
|
||||
var ?loop:Bool;
|
||||
|
||||
/**
|
||||
* Whether to check for `SongMusicData` to update the Conductor with.
|
||||
* @default `true`
|
||||
|
|
|
@ -13,6 +13,7 @@ import flixel.text.FlxBitmapText;
|
|||
import flixel.tweens.FlxEase;
|
||||
import funkin.ui.freeplay.FreeplayState;
|
||||
import flixel.tweens.FlxTween;
|
||||
import funkin.audio.FunkinSound;
|
||||
import flixel.util.FlxGradient;
|
||||
import flixel.util.FlxTimer;
|
||||
import funkin.graphics.shaders.LeftMaskShader;
|
||||
|
@ -48,9 +49,13 @@ class ResultState extends MusicBeatSubState
|
|||
else
|
||||
resultsVariation = NORMAL;
|
||||
|
||||
var loops:Bool = resultsVariation != SHIT;
|
||||
|
||||
FlxG.sound.playMusic(Paths.music("results" + resultsVariation), 1, loops);
|
||||
FunkinSound.playMusic('results$resultsVariation',
|
||||
{
|
||||
startingVolume: 1.0,
|
||||
overrideExisting: true,
|
||||
restartTrack: true,
|
||||
loop: resultsVariation != SHIT
|
||||
});
|
||||
|
||||
// TEMP-ish, just used to sorta "cache" the 3000x3000 image!
|
||||
var cacheBullShit:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/soundSystem"));
|
||||
|
@ -348,9 +353,12 @@ class ResultState extends MusicBeatSubState
|
|||
if (controls.PAUSE)
|
||||
{
|
||||
FlxTween.tween(FlxG.sound.music, {volume: 0}, 0.8);
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 3}, 0.1, {onComplete: _ -> {
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 0.5}, 0.4);
|
||||
}});
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 3}, 0.1,
|
||||
{
|
||||
onComplete: _ -> {
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 0.5}, 0.4);
|
||||
}
|
||||
});
|
||||
if (params.storyMode)
|
||||
{
|
||||
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new StoryMenuState(sticker)));
|
||||
|
|
|
@ -71,8 +71,6 @@ class LatencyState extends MusicBeatSubState
|
|||
// trace("EVENT LISTENER: " + key);
|
||||
});
|
||||
|
||||
// FlxG.sound.playMusic(Paths.sound('soundTest'));
|
||||
|
||||
// funnyStatsGraph.hi
|
||||
|
||||
Conductor.instance.forceBPM(60);
|
||||
|
|
|
@ -1131,7 +1131,6 @@ class FreeplayState extends MusicBeatSubState
|
|||
function changeSelection(change:Int = 0):Void
|
||||
{
|
||||
FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4);
|
||||
// FlxG.sound.playMusic(Paths.inst(songs[curSelected].songName));
|
||||
|
||||
var prevSelected:Int = curSelected;
|
||||
|
||||
|
@ -1174,20 +1173,25 @@ class FreeplayState extends MusicBeatSubState
|
|||
{
|
||||
if (curSelected == 0)
|
||||
{
|
||||
FlxG.sound.playMusic(Paths.music('freeplay/freeplayRandom'), 0);
|
||||
FunkinSound.playMusic('freeplayRandom',
|
||||
{
|
||||
startingVolume: 0.0,
|
||||
overrideExisting: true,
|
||||
restartTrack: true
|
||||
});
|
||||
FlxG.sound.music.fadeIn(2, 0, 0.8);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Stream the instrumental of the selected song?
|
||||
if (prevSelected == 0)
|
||||
var didReplace:Bool = FunkinSound.playMusic('freakyMenu',
|
||||
{
|
||||
startingVolume: 0.0,
|
||||
overrideExisting: true,
|
||||
restartTrack: false
|
||||
});
|
||||
if (didReplace)
|
||||
{
|
||||
FunkinSound.playMusic('freakyMenu',
|
||||
{
|
||||
startingVolume: 0.0,
|
||||
overrideExisting: true,
|
||||
restartTrack: false
|
||||
});
|
||||
FlxG.sound.music.fadeIn(2, 0, 0.8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -389,8 +389,6 @@ class TitleState extends MusicBeatState
|
|||
{
|
||||
cheatActive = true;
|
||||
|
||||
FlxG.sound.playMusic(Paths.music('tutorialTitle'), 1);
|
||||
|
||||
var spec:SpectogramSprite = new SpectogramSprite(FlxG.sound.music);
|
||||
add(spec);
|
||||
|
||||
|
|
Loading…
Reference in a new issue