generated from Joalor64GH/HaxeFlixel-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c0d314
commit 6d1da4c
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package states; | ||
|
||
class EditorState extends ExtendableState { | ||
final options:Array<String> = [ | ||
"Chart Editor", | ||
"Song Selection Editor" | ||
]; | ||
var grpOptions:FlxTypedGroup<FlxText>; | ||
var curSelected:Int = 0; | ||
var daText:FlxText; | ||
|
||
override function create() { | ||
super.create(); | ||
|
||
var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('options/options_bg')); | ||
add(bg); | ||
|
||
var grid:FlxBackdrop = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x33FFFFFF, 0x0)); | ||
grid.velocity.set(40, 40); | ||
add(grid); | ||
|
||
grpOptions = new FlxTypedGroup<FlxText>(); | ||
add(grpOptions); | ||
|
||
for (i in 0...options.length) { | ||
var optionTxt:FlxText = new FlxText(20, 20 + (i * 50), 0, options[i], 32); | ||
optionTxt.setFormat(Paths.font('vcr.ttf'), 60, FlxColor.WHITE, FlxTextAlign.LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); | ||
optionTxt.ID = i; | ||
grpOptions.add(optionTxt); | ||
} | ||
|
||
daText = new FlxText(5, FlxG.height - 24, 0, "", 12); | ||
daText.setFormat(Paths.font('vcr.ttf'), 20, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); | ||
add(daText); | ||
} | ||
|
||
override function update(elapsed:Float) { | ||
super.update(elapsed); | ||
|
||
updateText(); | ||
|
||
if (Input.is('up') || Input.is('down')) | ||
changeSelection(Input.is('up') ? -1 : 1); | ||
|
||
if (Input.is('exit')) { | ||
ExtendableState.switchState(new MenuState()); | ||
FlxG.sound.play(Paths.sound('cancel')); | ||
} | ||
} | ||
|
||
private function changeSelection(change:Int = 0) { | ||
FlxG.sound.play(Paths.sound('scroll')); | ||
curSelected = FlxMath.wrap(curSelected + change, 0, options.length - 1); | ||
grpOptions.forEach(function(txt:FlxText) { | ||
txt.alpha = (txt.ID == curSelected) ? 1 : 0.6; | ||
}); | ||
} | ||
|
||
function updateText() { | ||
switch (curSelected) { | ||
case 0: daText.text = "Making your own chart"; | ||
case 1: daText.text = "Add your own song onto play selection"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters