mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-27 09:13:18 +00:00
cool pause music
This commit is contained in:
parent
3451d1ce5b
commit
36b0302ac4
|
@ -34,7 +34,8 @@ class MusicBeatState extends FlxUIState
|
||||||
everyStep();
|
everyStep();
|
||||||
|
|
||||||
updateCurStep();
|
updateCurStep();
|
||||||
curBeat = Math.floor(curStep / 4);
|
// Needs to be ROUNED, rather than ceil or floor
|
||||||
|
curBeat = Math.round(curStep / 4);
|
||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ class MusicBeatState extends FlxUIState
|
||||||
if (Conductor.songPosition > lastStep + (Conductor.stepCrochet * 3))
|
if (Conductor.songPosition > lastStep + (Conductor.stepCrochet * 3))
|
||||||
{
|
{
|
||||||
lastStep = Conductor.songPosition;
|
lastStep = Conductor.songPosition;
|
||||||
totalSteps = Math.round(lastStep / Conductor.stepCrochet);
|
totalSteps = Math.ceil(lastStep / Conductor.stepCrochet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalSteps % 4 == 0)
|
if (totalSteps % 4 == 0)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import flixel.FlxSprite;
|
||||||
import flixel.FlxSubState;
|
import flixel.FlxSubState;
|
||||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||||
import flixel.input.keyboard.FlxKey;
|
import flixel.input.keyboard.FlxKey;
|
||||||
|
import flixel.system.FlxSound;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
|
|
||||||
class PauseSubState extends MusicBeatSubstate
|
class PauseSubState extends MusicBeatSubstate
|
||||||
|
@ -15,9 +16,18 @@ class PauseSubState extends MusicBeatSubstate
|
||||||
var menuItems:Array<String> = ['Resume', 'Restart Song', 'Exit to menu'];
|
var menuItems:Array<String> = ['Resume', 'Restart Song', 'Exit to menu'];
|
||||||
var curSelected:Int = 0;
|
var curSelected:Int = 0;
|
||||||
|
|
||||||
|
var pauseMusic:FlxSound;
|
||||||
|
|
||||||
public function new(x:Float, y:Float)
|
public function new(x:Float, y:Float)
|
||||||
{
|
{
|
||||||
super();
|
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);
|
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
|
||||||
bg.alpha = 0.6;
|
bg.alpha = 0.6;
|
||||||
bg.scrollFactor.set();
|
bg.scrollFactor.set();
|
||||||
|
@ -41,6 +51,9 @@ class PauseSubState extends MusicBeatSubstate
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
|
if (pauseMusic.volume < 0.5)
|
||||||
|
pauseMusic.volume += 0.01 * elapsed;
|
||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
var upP = controls.UP_P;
|
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
|
function changeSelection(change:Int = 0):Void
|
||||||
{
|
{
|
||||||
curSelected += change;
|
curSelected += change;
|
||||||
|
|
|
@ -588,6 +588,7 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
private var paused:Bool = false;
|
private var paused:Bool = false;
|
||||||
var startedCountdown:Bool = false;
|
var startedCountdown:Bool = false;
|
||||||
|
var canPause:Bool = true;
|
||||||
|
|
||||||
override public function update(elapsed:Float)
|
override public function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
|
@ -595,7 +596,7 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
scoreTxt.text = "Score:" + songScore;
|
scoreTxt.text = "Score:" + songScore;
|
||||||
|
|
||||||
if (FlxG.keys.justPressed.ENTER && startedCountdown)
|
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
|
||||||
{
|
{
|
||||||
persistentUpdate = false;
|
persistentUpdate = false;
|
||||||
persistentDraw = true;
|
persistentDraw = true;
|
||||||
|
@ -830,6 +831,8 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
function endSong():Void
|
function endSong():Void
|
||||||
{
|
{
|
||||||
|
canPause = false;
|
||||||
|
|
||||||
Highscore.saveScore(SONG.song, songScore, storyDifficulty);
|
Highscore.saveScore(SONG.song, songScore, storyDifficulty);
|
||||||
|
|
||||||
if (isStoryMode)
|
if (isStoryMode)
|
||||||
|
|
Loading…
Reference in a new issue