Initial Commit
* Adds Menu * Adds Level Manager - LevelBase * Adds Sample level * Basic player movement
This commit is contained in:
81
source/scenes/MenuState.hx
Normal file
81
source/scenes/MenuState.hx
Normal file
@@ -0,0 +1,81 @@
|
||||
package scenes;
|
||||
|
||||
import djFlixel.gfx.StarfieldSimple;
|
||||
import djFlixel.gfx.pal.Pal_DB32;
|
||||
import djFlixel.ui.FlxMenu;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxState;
|
||||
import openfl.system.System;
|
||||
|
||||
class MenuState extends FlxState
|
||||
{
|
||||
override public function create()
|
||||
{
|
||||
super.create();
|
||||
this.generateStarField();
|
||||
this.createMenu();
|
||||
}
|
||||
|
||||
private function generateStarField()
|
||||
{
|
||||
var stars = new StarfieldSimple();
|
||||
stars.WIDE_PIXEL = false;
|
||||
stars.STAR_SPEED = 1.9;
|
||||
add(stars);
|
||||
}
|
||||
|
||||
private function createMenu()
|
||||
{
|
||||
var _menu = new FlxMenu(FlxG.width / 2 - (70 - 20), FlxG.height / 2 + 40, 140);
|
||||
_menu.stI.text = {
|
||||
f: AssetPaths.MrPixel__otf,
|
||||
s: 20,
|
||||
bt: 1,
|
||||
so: [1, 1]
|
||||
};
|
||||
_menu.PARAMS.enable_mouse = false;
|
||||
_menu.stI.col_t = {
|
||||
idle: Pal_DB32.COL[21],
|
||||
focus: Pal_DB32.COL[28],
|
||||
accent: Pal_DB32.COL[29],
|
||||
dis: Pal_DB32.COL[25], // Disabled
|
||||
dis_f: Pal_DB32.COL[23], // Disabled focused
|
||||
};
|
||||
_menu.stI.col_b = {
|
||||
idle: Pal_DB32.COL[1],
|
||||
focus: Pal_DB32.COL[0]
|
||||
};
|
||||
_menu.stHeader = {
|
||||
f: AssetPaths.MrPixel__otf,
|
||||
s: 16,
|
||||
bt: 2,
|
||||
bs: 1,
|
||||
c: Pal_DB32.COL[8],
|
||||
bc: Pal_DB32.COL[27]
|
||||
};
|
||||
_menu.PARAMS.header_CPS = 30;
|
||||
_menu.PARAMS.page_anim_parallel = true;
|
||||
_menu.createPage('main').addM(['Start |link|gamestart', 'Credits |link|credits', 'Exit |link|exit']);
|
||||
|
||||
_menu.onItemEvent = (a, b) ->
|
||||
{
|
||||
if (a == fire)
|
||||
{
|
||||
switch (b.ID)
|
||||
{
|
||||
case 'gamestart': this.switchState(new Level1());
|
||||
case 'credits': this.switchState(new Credits());
|
||||
case 'exit': System.exit(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
add(_menu);
|
||||
_menu.goto('main');
|
||||
}
|
||||
|
||||
private function switchState(state)
|
||||
{
|
||||
FlxG.switchState(state);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user