redoing and replacing some of the music logic
This commit is contained in:
53
source/MusicBeatState.hx
Normal file
53
source/MusicBeatState.hx
Normal file
@ -0,0 +1,53 @@
|
||||
package;
|
||||
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
|
||||
class MusicBeatState extends FlxTransitionableState
|
||||
{
|
||||
private var lastBeat:Float = 0;
|
||||
private var lastStep:Float = 0;
|
||||
|
||||
private var totalBeats:Int = 0;
|
||||
private var totalSteps:Int = 0;
|
||||
|
||||
override function create()
|
||||
{
|
||||
super.create();
|
||||
}
|
||||
|
||||
private function everyBeat():Void
|
||||
{
|
||||
if (Conductor.songPosition > lastBeat + Conductor.crochet - Conductor.safeZoneOffset
|
||||
|| Conductor.songPosition < lastBeat + Conductor.safeZoneOffset)
|
||||
{
|
||||
if (Conductor.songPosition > lastBeat + Conductor.crochet)
|
||||
{
|
||||
beatHit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function everyStep():Void
|
||||
{
|
||||
if (Conductor.songPosition > lastStep + Conductor.stepCrochet - Conductor.safeZoneOffset
|
||||
|| Conductor.songPosition < lastStep + Conductor.safeZoneOffset)
|
||||
{
|
||||
if (Conductor.songPosition > lastStep + Conductor.stepCrochet)
|
||||
{
|
||||
stepHit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function stepHit():Void
|
||||
{
|
||||
totalSteps += 1;
|
||||
lastStep += Conductor.stepCrochet;
|
||||
}
|
||||
|
||||
public function beatHit():Void
|
||||
{
|
||||
lastBeat += Conductor.crochet;
|
||||
totalBeats += 1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user