aboutsummaryrefslogtreecommitdiff
path: root/source/core/MenuState.hx
blob: e8b30bf66fc812a89cc1710ce65922ce1facb819 (plain)
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
package core;

import flixel.FlxG;
import flixel.FlxState;
import flixel.addons.display.FlxStarField.FlxStarField2D;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import levels.Level1;
import utils.Constants;
import utils.Debug;

class MenuState extends FlxState
{
	override public function create()
	{
		Debug.log("Menu State");
		var title1 = generateText("Your Enemy is in Another", 24, Constants.defaultFont);
		var title2 = generateText("Dungeon", 30, Constants.stylyzedFont);
		title2.y = title2.y + 25;
		title2.color = FlxColor.RED;
		title2.angle = -9.74;
		var starfield:FlxStarField2D = new FlxStarField2D(0, 0, FlxG.width, FlxG.height, 500);
		add(starfield);
		add(title1);
		add(title2);
		if (FlxG.sound.music == null)
		{
			FlxG.sound.playMusic(AssetPaths.TitleMusic__ogg, 1, true);
		}
		super.create();
	}

	override public function update(dt:Float)
	{
		if (FlxG.keys.anyPressed([X]))
		{
			FlxG.sound.music.stop();
			FlxG.switchState(new Level1());
		}
		super.update(dt);
	}

	private function generateText(text:String, size:Int, font:String)
	{
		var displayText:FlxText = new FlxText();
		displayText.text = text;
		displayText.size = size;
		displayText.font = font;
		displayText.screenCenter();
		return displayText;
	}
}