mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-25 22:47:52 +00:00
Fixed TitleState not firing onBeat
This commit is contained in:
parent
679ca4aafb
commit
8a2e4687b2
|
@ -34,16 +34,21 @@ class Conductor
|
|||
/**
|
||||
* Beats per minute of the current song at the current time.
|
||||
*/
|
||||
public static var bpm(get, null):Float = 100;
|
||||
public static var bpm(get, null):Float;
|
||||
|
||||
static function get_bpm():Float
|
||||
{
|
||||
if (bpmOverride != null)
|
||||
return bpmOverride;
|
||||
|
||||
if (currentTimeChange == null)
|
||||
return 100;
|
||||
|
||||
return currentTimeChange.bpm;
|
||||
}
|
||||
|
||||
static var bpmOverride:Null<Float> = null;
|
||||
|
||||
// OLD, replaced with timeChanges.
|
||||
public static var bpmChangeMap:Array<BPMChangeEvent> = [];
|
||||
|
||||
|
@ -111,23 +116,29 @@ class Conductor
|
|||
return lastChange;
|
||||
}
|
||||
|
||||
@:deprecated // Use loadSong with metadata files instead.
|
||||
public static function forceBPM(bpm:Float)
|
||||
{
|
||||
// TODO: Get rid of this and use song metadata instead.
|
||||
Conductor.bpm = bpm;
|
||||
Conductor.bpmOverride = bpm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the conductor with the current song position.
|
||||
* BPM, current step, etc. will be re-calculated based on the song position.
|
||||
*
|
||||
* @param songPosition The current position in the song in milliseconds.
|
||||
* Leave blank to use the FlxG.sound.music position.
|
||||
*/
|
||||
public static function update(songPosition:Float)
|
||||
public static function update(songPosition:Float = null)
|
||||
{
|
||||
if (songPosition == null)
|
||||
songPosition = (FlxG.sound.music != null) ? (FlxG.sound.music.time + Conductor.offset) : 0;
|
||||
|
||||
var oldBeat = currentBeat;
|
||||
var oldStep = currentStep;
|
||||
|
||||
Conductor.songPosition = songPosition;
|
||||
Conductor.bpm = Conductor.getLastBPMChange().bpm;
|
||||
// Conductor.bpm = Conductor.getLastBPMChange().bpm;
|
||||
|
||||
currentTimeChange = timeChanges[0];
|
||||
for (i in 0...timeChanges.length)
|
||||
|
@ -139,15 +150,21 @@ class Conductor
|
|||
break;
|
||||
}
|
||||
|
||||
if (currentTimeChange == null)
|
||||
if (currentTimeChange == null && bpmOverride == null)
|
||||
{
|
||||
trace('WARNING: Conductor is broken, timeChanges is empty.');
|
||||
}
|
||||
else
|
||||
else if (currentTimeChange != null)
|
||||
{
|
||||
currentStep = Math.floor((currentTimeChange.beatTime * 4) + (songPosition - currentTimeChange.timeStamp) / stepCrochet);
|
||||
currentBeat = Math.floor(currentStep / 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a constant BPM equal to the forced value.
|
||||
currentStep = Math.floor((songPosition) / stepCrochet);
|
||||
currentBeat = Math.floor(currentStep / 4);
|
||||
}
|
||||
|
||||
// FlxSignals are really cool.
|
||||
if (currentStep != oldStep)
|
||||
|
@ -157,6 +174,7 @@ class Conductor
|
|||
beatHit.dispatch();
|
||||
}
|
||||
|
||||
@:deprecated // Switch to TimeChanges instead.
|
||||
public static function mapBPMChanges(song:SwagSong)
|
||||
{
|
||||
bpmChangeMap = [];
|
||||
|
@ -181,7 +199,6 @@ class Conductor
|
|||
totalSteps += deltaSteps;
|
||||
totalPos += ((60 / curBPM) * 1000 / 4) * deltaSteps;
|
||||
}
|
||||
trace("new BPM map BUDDY " + bpmChangeMap);
|
||||
}
|
||||
|
||||
public static function mapTimeChanges(currentChart:SongDifficulty)
|
||||
|
|
|
@ -259,6 +259,8 @@ class TitleState extends MusicBeatState
|
|||
FlxG.sound.music.pitch -= 0.5 * elapsed;
|
||||
#end
|
||||
|
||||
Conductor.update();
|
||||
|
||||
/* if (FlxG.onMobile)
|
||||
{
|
||||
if (gfDance != null)
|
||||
|
|
|
@ -1786,7 +1786,7 @@ class PlayState extends MusicBeatState
|
|||
// BPM might change between the current and target section but IDGAF
|
||||
FlxG.sound.music.time = Conductor.songPosition + (sec * 4 * (1000 * 60 / Conductor.bpm));
|
||||
|
||||
Conductor.update(FlxG.sound.music.time + Conductor.offset);
|
||||
Conductor.update();
|
||||
resyncVocals();
|
||||
}
|
||||
#end
|
||||
|
|
|
@ -114,6 +114,11 @@ class SongDataParser
|
|||
}
|
||||
}
|
||||
|
||||
public static function listSongIds():Array<String>
|
||||
{
|
||||
return [for (x in songCache.keys()) x];
|
||||
}
|
||||
|
||||
public static function parseSongMetadata(songId:String):Array<SongMetadata>
|
||||
{
|
||||
var result:Array<SongMetadata> = [];
|
||||
|
|
Loading…
Reference in a new issue