new options
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
package funkin.options;
|
||||
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxG;
|
||||
import funkin.options.type.OptionType;
|
||||
/**
|
||||
* Direct replica from Week 7 lol
|
||||
*/
|
||||
class OptionsScreen extends MusicBeatState {
|
||||
public static inline var defaultBGColor:FlxColor = 0xFFFDE871;
|
||||
|
||||
public var bgColor:FlxColor = 0xFFFDE871;
|
||||
public static var instance:OptionsScreen;
|
||||
|
||||
// public var bgColor:FlxColor = 0xFFFDE871;
|
||||
public var bg:FlxSprite;
|
||||
public var curSelected:Int = -1;
|
||||
|
||||
public var options:Array<OptionType> = [];
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public override function create() {
|
||||
super.create();
|
||||
@@ -22,5 +34,35 @@ class OptionsScreen extends MusicBeatState {
|
||||
bg.screenCenter();
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
|
||||
for(k=>option in options) {
|
||||
option.setPosition(0, 10 + (k * 120));
|
||||
add(option);
|
||||
}
|
||||
changeSelection(1);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
changeSelection((controls.DOWN_P ? 1 : 0) + (controls.UP_P ? -1 : 0));
|
||||
if (controls.ACCEPT) {
|
||||
options[curSelected].onSelect();
|
||||
}
|
||||
if (controls.BACK)
|
||||
FlxG.switchState(new OptionsMenu(false));
|
||||
}
|
||||
|
||||
public function changeSelection(change:Int) {
|
||||
if (change == 0 && curSelected != -1) return;
|
||||
curSelected = FlxMath.wrap(curSelected + change, 0, options.length - 1);
|
||||
for(e in options)
|
||||
e.selected = false;
|
||||
options[curSelected].selected = true;
|
||||
CoolUtil.playMenuSFX(0);
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user