//... public MainMenu(Game gm, MainField fld, int W, int H) : base(gm) { field = fld; panel = new SpriteBatch(this.Game.GraphicsDevice); run_image = new Texture2D[2]; end_image = new Texture2D[3]; rect = new Rectangle[3]; //TODO: Scaling position of buttons //: ... int s = ((W < H)? (W): (H)) / 400; rect[0] = new Rectangle(W / 2 - 150 * s, H / 2 - 50 * s, 300 * s, 100 * s); rect[1] = new Rectangle(W / 2 - 150 * s, (W / 3 + (H - W / 3) / 2) - 50 * s, 300 * s, 100 * s); rect[2] = new Rectangle(0, 0, W, W / 3); //... LoadContent(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { //... base.Initialize(); //... //int w = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, h = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; int w = graphics.PreferredBackBufferWidth, h = graphics.PreferredBackBufferHeight; int s = (h < w)? (h): (w); s = (4 * s) / 5; field = new MainField(this, new Rectangle(w / 2 - s / 2, h / 2 - s / 2, s, s), new Point(8, 8), timeLimit); menu = new MainMenu(this, field, w, h); //... Components.Add(field); field.Enabled = field.Visible = false; Components.Add(menu); //menu.Enabled = menu.Visible = false; //... }