//List<Sprite> _menuElements; public PauseMenu(TheGame game) { _background = new Sprite(this, "pause", new Vector2(0, 0), new Vector2(300, 400)); _resume = new Button("button", "Resume", Color.Cyan, new Vector2(0, 0), new Vector2(150, 40), this); _controls = new Button("button", "Controls", Color.Orange, new Vector2(0, 0), new Vector2(150, 40), this); _restart = new Button("button", "Restart", Color.Lime, new Vector2(0, 0), new Vector2(150, 40), this); _mainMenu = new Button("button", "Main Menu", Color.Yellow, new Vector2(0, 0), new Vector2(150, 40), this); _quit = new Button("button","Quit",Color.Red, new Vector2(0, 0), new Vector2(150, 40), this); MenuElements = new List<Sprite>(); MenuElements.Add(_background); MenuElements.Add(_resume); MenuElements.Add(_restart); MenuElements.Add(_mainMenu); MenuElements.Add(_controls); MenuElements.Add(_quit); _background.Color = Color.White; _resume.AddOnClickListener(Resume); _controls.AddOnClickListener(Menu.MainMenu.goToChildMenu, "mainControls"); _quit.AddOnClickListener(game.Exit); _restart.AddOnClickListener(game.LoadLevel); _mainMenu.AddOnClickListener(OpenMainMenu); Id = "pause"; InputManager.AddKeyboardCallback(Keys.Escape, Pause, InputManager.InputState.OnInputDown, null, true); InputManager.AddKeyboardCallback(Keys.Escape, Resume, InputManager.InputState.OnInputDown, this, true); Active = true; for (int i = 0; i < MenuElements.Count; i++) MenuElements[i].LayerDepth = 0.29f - i / 100; }
static void Main() { using (var game = new TheGame()) game.Run(); }