1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-27 01:03:35 +00:00

cool pause music

This commit is contained in:
Cameron Taylor 2020-11-20 04:21:04 -08:00
parent 3451d1ce5b
commit 36b0302ac4
3 changed files with 27 additions and 3 deletions

View file

@ -34,7 +34,8 @@ class MusicBeatState extends FlxUIState
everyStep();
updateCurStep();
curBeat = Math.floor(curStep / 4);
// Needs to be ROUNED, rather than ceil or floor
curBeat = Math.round(curStep / 4);
super.update(elapsed);
}
@ -68,7 +69,7 @@ class MusicBeatState extends FlxUIState
if (Conductor.songPosition > lastStep + (Conductor.stepCrochet * 3))
{
lastStep = Conductor.songPosition;
totalSteps = Math.round(lastStep / Conductor.stepCrochet);
totalSteps = Math.ceil(lastStep / Conductor.stepCrochet);
}
if (totalSteps % 4 == 0)

View file

@ -6,6 +6,7 @@ import flixel.FlxSprite;
import flixel.FlxSubState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.input.keyboard.FlxKey;
import flixel.system.FlxSound;
import flixel.util.FlxColor;
class PauseSubState extends MusicBeatSubstate
@ -15,9 +16,18 @@ class PauseSubState extends MusicBeatSubstate
var menuItems:Array<String> = ['Resume', 'Restart Song', 'Exit to menu'];
var curSelected:Int = 0;
var pauseMusic:FlxSound;
public function new(x:Float, y:Float)
{
super();
pauseMusic = new FlxSound().loadEmbedded('assets/music/breakfast' + TitleState.soundExt, true, true);
pauseMusic.volume = 0;
pauseMusic.play(false, FlxG.random.int(0, Std.int(pauseMusic.length / 2)));
FlxG.sound.list.add(pauseMusic);
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.alpha = 0.6;
bg.scrollFactor.set();
@ -41,6 +51,9 @@ class PauseSubState extends MusicBeatSubstate
override function update(elapsed:Float)
{
if (pauseMusic.volume < 0.5)
pauseMusic.volume += 0.01 * elapsed;
super.update(elapsed);
var upP = controls.UP_P;
@ -78,6 +91,13 @@ class PauseSubState extends MusicBeatSubstate
}
}
override function destroy()
{
pauseMusic.destroy();
super.destroy();
}
function changeSelection(change:Int = 0):Void
{
curSelected += change;

View file

@ -588,6 +588,7 @@ class PlayState extends MusicBeatState
private var paused:Bool = false;
var startedCountdown:Bool = false;
var canPause:Bool = true;
override public function update(elapsed:Float)
{
@ -595,7 +596,7 @@ class PlayState extends MusicBeatState
scoreTxt.text = "Score:" + songScore;
if (FlxG.keys.justPressed.ENTER && startedCountdown)
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
{
persistentUpdate = false;
persistentDraw = true;
@ -830,6 +831,8 @@ class PlayState extends MusicBeatState
function endSong():Void
{
canPause = false;
Highscore.saveScore(SONG.song, songScore, storyDifficulty);
if (isStoryMode)