コード例 #1
0
ファイル: MenuScene.cs プロジェクト: dcrn/gameoflife
        public override void Initialize()
        {
            // Background
            canvas = new Panel();
            canvas.Color = Color.RoyalBlue;
            canvas.Width = Game1.instance.GraphicsDevice.Viewport.Width;
            canvas.Height = Game1.instance.GraphicsDevice.Viewport.Height;

            // Title text
            title = new Label();
            title.Font = Game1.instance.titlefont;
            title.Text = "Conway's Game of Life";
            title.SizeToContents();
            title.Y = 40;
            canvas.Add(title);
            title.CenterX();

            // Menu area
            menubox = new Panel();
            menubox.Color = Color.CornflowerBlue;
            menubox.Width = 200;
            menubox.Height = 190;
            canvas.Add(menubox);
            menubox.Center();

            // Play button
            TextButton playButton = new TextButton();
            playButton.Font = Game1.instance.titlefont;
            playButton.Color = Color.RoyalBlue;
            playButton.Text = "Play";
            playButton.Width = 180;
            playButton.Height = 80;
            playButton.X = 10;
            playButton.Y = 10;

            // Exit button
            TextButton exitButton = new TextButton();
            exitButton.Font = Game1.instance.titlefont;
            exitButton.Color = Color.RoyalBlue;
            exitButton.Text = "Exit";
            exitButton.Width = 180;
            exitButton.Height = 80;
            exitButton.X = 10;
            exitButton.Y = 100;

            // Add buttons to menu box
            menubox.Add(playButton);
            menubox.Add(exitButton);

            // Button events
            playButton.OnClick += delegate { Play(); };
            exitButton.OnClick += delegate { Game1.instance.Exit(); };
        }
コード例 #2
0
ファイル: TextButton.cs プロジェクト: dcrn/gameoflife
 public TextButton()
     : base()
 {
     label = new Label();
     this.Add(label);
 }