forked from RyoleBg/PE-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFreeplaySelectState.hx
71 lines (63 loc) · 1.89 KB
/
FreeplaySelectState.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.FlxSprite;
import flixel.FlxG;
class FreeplaySelectState extends MusicBeatState{
var freeplayCats:Array<String> = ['Vanilla', 'Tutorials'];
var grpCats:FlxTypedGroup<Alphabet>;
var curSelected:Int = 0;
var BG:FlxSprite;
override function create(){
BG = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
BG.updateHitbox();
BG.screenCenter();
add(BG);
grpCats = new FlxTypedGroup<Alphabet>();
add(grpCats);
for (i in 0...freeplayCats.length)
{
var catsText:Alphabet = new Alphabet(0, (70 * i) + 30, freeplayCats[i], true, false);
catsText.targetY = i;
catsText.isMenuItem = true;
grpCats.add(catsText);
}
changeSelection();
super.create();
}
override public function update(elapsed:Float){
if (controls.UI_UP_P)
changeSelection(-1);
if (controls.UI_DOWN_P)
changeSelection(1);
if (controls.BACK) {
FlxG.sound.play(Paths.sound('cancelMenu'));
MusicBeatState.switchState(new MainMenuState());
}
if (controls.ACCEPT){
switch(curSelected){
case 0:
MusicBeatState.switchState(new FreeplayState());
case 1:
MusicBeatState.switchState(new FreeplayCategory2State());
}
}
super.update(elapsed);
}
function changeSelection(change:Int = 0) {
curSelected += change;
if (curSelected < 0)
curSelected = freeplayCats.length - 1;
if (curSelected >= freeplayCats.length)
curSelected = 0;
var bullShit:Int = 0;
for (item in grpCats.members) {
item.targetY = bullShit - curSelected;
bullShit++;
item.alpha = 0.6;
if (item.targetY == 0) {
item.alpha = 1;
}
}
FlxG.sound.play(Paths.sound('scrollMenu'));
}
}