1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-29 18:24:23 +00:00

sequencer in progress

This commit is contained in:
Cameron Taylor 2020-10-09 21:22:26 -07:00
parent daa41dafe1
commit 29615f24f7
2 changed files with 65 additions and 18 deletions

View file

@ -2,6 +2,7 @@
"lineEnds": { "lineEnds": {
"leftCurly": "both", "leftCurly": "both",
"rightCurly": "both", "rightCurly": "both",
"emptyCurly": "break",
"objectLiteralCurly": { "objectLiteralCurly": {
"leftCurly": "after" "leftCurly": "after"
} }

View file

@ -2,7 +2,10 @@ package;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxState; import flixel.FlxState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.ui.FlxButton; import flixel.ui.FlxButton;
import flixel.ui.FlxSpriteButton;
import flixel.util.FlxColor;
import haxe.Json; import haxe.Json;
import openfl.events.Event; import openfl.events.Event;
import openfl.events.IOErrorEvent; import openfl.events.IOErrorEvent;
@ -13,13 +16,61 @@ import openfl.net.FileReference;
class ChartingState extends MusicBeatState class ChartingState extends MusicBeatState
{ {
var _file:FileReference; var _file:FileReference;
var sequencer:FlxTypedGroup<FlxSpriteButton>;
var notes:Array<Dynamic> = [];
override function create() override function create()
{ {
var saveButton:FlxButton = new FlxButton(0, 0, "Save", function() var saveButton:FlxButton = new FlxButton(0, 0, "Save", function()
{ {
// bullshit saveLevel();
});
saveButton.screenCenter();
add(saveButton);
createStepChart();
super.create();
}
function createStepChart()
{
sequencer = new FlxTypedGroup<FlxSpriteButton>();
add(sequencer);
for (r in 0...2)
{
notes.push([]);
for (i in 0...16)
{
notes[r].push(false);
var seqBtn:FlxSpriteButton = new FlxSpriteButton((35 * r) + 10, (35 * i) + 50, null, function()
{
notes[r][i] = !notes[r][i];
});
seqBtn.makeGraphic(30, 30, FlxColor.WHITE);
seqBtn.ID = i + (16 * r);
sequencer.add(seqBtn);
}
}
}
override function update(elapsed:Float)
{
sequencer.forEach(function(spr:FlxSpriteButton)
{
if (notes[Std.int(spr.ID / 16)][spr.ID % 16])
spr.alpha = 1;
else
spr.alpha = 0.5;
});
super.update(elapsed);
}
private function saveLevel()
{
var json = { var json = {
"song": "Bopeebo", "song": "Bopeebo",
"bpm": 100, "bpm": 100,
@ -36,11 +87,6 @@ class ChartingState extends MusicBeatState
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError); _file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
_file.save(data, json.song + ".json"); _file.save(data, json.song + ".json");
} }
});
saveButton.screenCenter();
add(saveButton);
super.create();
} }
function onSaveComplete(_):Void function onSaveComplete(_):Void