package gameStates
{
	import org.flixel.*;
	
	
	public class MenuState extends FlxState
	{			

		private var Subtitle:FlxText;
		[Embed(source = "../../assets/images/menuBg.png")]public var bgPNG:Class;
		[Embed(source = "../../assets/audio/robotito-base 5-Clean2 Bright Guitar.mp3")]public var snd2:Class;
		
		
		override public function create():void
		{
			var spriteFondo:FlxSprite = new FlxSprite(0,0,bgPNG);
			add(spriteFondo); 
			
			
			Subtitle = new FlxText(0,FlxG.height/2 + 200,FlxG.width," SPACE to Start Game");
			Subtitle.size = 12;
			Subtitle.alignment = "center";
			Subtitle.scrollFactor.x = 0;
			Subtitle.scrollFactor.y = 0;
			Subtitle.color = 0xFFFFFF;
			add(Subtitle);
			
			FlxG.playMusic(snd2, 1);
			
		}

		override public function update():void
		{
			super.update();
			
			if (FlxG.keys.justPressed("SPACE"))
			{
				onButton();
			}
			
			if (FlxG.keys.justPressed("C"))
			{
				credits();
			}
		}
		
		private function onButton():void
		{
			FlxG.flash(0xffc2c2c2, 0.5);
			FlxG.fade(0xff000000, 0.5, onFade);
		}
		
		private function onFade():void
		{
			Registry.init();
			FlxG.mouse.hide();
			FlxG.switchState(new StoryState);
		}
		
		public function credits():void
		{
			FlxG.switchState(new CreditsState)
		}
		
	}

}