112 lines
3.1 KiB
Haxe
112 lines
3.1 KiB
Haxe
package scenes;
|
|
|
|
import djFlixel.gfx.StarfieldSimple;
|
|
import djFlixel.gfx.pal.Pal_DB32;
|
|
import djFlixel.ui.FlxMenu;
|
|
import flixel.FlxG;
|
|
import flixel.FlxState;
|
|
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
|
|
import flixel.addons.transition.FlxTransitionableState;
|
|
import flixel.addons.transition.TransitionData;
|
|
import flixel.graphics.FlxGraphic;
|
|
import flixel.util.FlxColor;
|
|
import openfl.system.System;
|
|
|
|
class MenuState extends FlxState
|
|
{
|
|
override public function create()
|
|
{
|
|
super.create();
|
|
createTransition();
|
|
this.generateStarField();
|
|
this.createMenu();
|
|
}
|
|
|
|
function createTransition()
|
|
{
|
|
FlxTransitionableState.defaultTransIn = new TransitionData(TILES, FlxColor.WHITE, 1.1);
|
|
FlxTransitionableState.defaultTransOut = new TransitionData(TILES, FlxColor.WHITE, 1.1);
|
|
var diamond:FlxGraphic = FlxGraphic.fromClass(cast GraphicTransTileDiamond);
|
|
diamond.persist = true;
|
|
diamond.destroyOnNoUse = false;
|
|
|
|
FlxTransitionableState.defaultTransIn.tileData = {asset: diamond, width: 32, height: 32};
|
|
FlxTransitionableState.defaultTransOut.tileData = {asset: diamond, width: 32, height: 32};
|
|
|
|
// FlxTransitionableState.defaultTransIn.color = FlxColor.WHITE;
|
|
// FlxTransitionableState.defaultTransIn.type = TILES;
|
|
// FlxTransitionableState.defaultTransIn.duration = 2;
|
|
// FlxTransitionableState.defaultTransIn.direction = new FlxPoint(1, 0);
|
|
// FlxTransitionableState.defaultTransIn.tileData.asset = diamond;
|
|
|
|
// FlxTransitionableState.defaultTransOut.color = FlxColor.WHITE;
|
|
// FlxTransitionableState.defaultTransOut.type = TILES;
|
|
// FlxTransitionableState.defaultTransOut.duration = 2;
|
|
// FlxTransitionableState.defaultTransOut.direction = new FlxPoint(1, 0);
|
|
// FlxTransitionableState.defaultTransOut.tileData.asset = diamond;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|