コード例 #1
0
        protected override void LoadContent()
        {
            //loading the main menu music
            menuSong = Content.Load <Song>("Music/MenuMusic");
            Lvl1to3  = Content.Load <Song>("Music/LevelMusic");
            MediaPlayer.Play(menuSong);

            //initializing timers
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 1000;
            aTimer.Enabled  = true;

            manager = new GameManager(this.Content);

            //initializing inGame menu
            inGameMenu_ = new InGameMenu(graphics.GraphicsDevice, Content, this, manager);


            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);


            gameBackground.Init(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, Content.Load <Texture2D>("Background/Level1"));

            // TODO: use this.Content to load your game content here
            MenuState_ = currentState = new MenuState(this, graphics.GraphicsDevice, Content);
        }
コード例 #2
0
        public LevelSelector(GraphicsDevice graphics, ContentManager content, Game1 game1Ref, GameManager gameMangerRef)
        {
            //setting up our ingame menu


            //setting up the variables for the Instructions side
            gameBackground.Init(graphics.Viewport.Width, graphics.Viewport.Height, content.Load <Texture2D>("Background/GameBackground"));
            IngameBackground.Init(graphics.Viewport.Width, graphics.Viewport.Height, content.Load <Texture2D>("Background/Level1"));

            this.graphics      = graphics;
            this.tempContent   = content;
            this.game1Ref      = game1Ref;
            this.gameMangerRef = gameMangerRef;

            inGameMenu_ = new InGameMenu(this.graphics, tempContent, this.game1Ref, gameMangerRef);

            rec = new Rectangle(graphics.Viewport.Width / 5, graphics.Viewport.Height / 100, 1080, 965);
            var buttonTexture    = content.Load <Texture2D>("Controls/gameButton");
            var buttonFont       = content.Load <SpriteFont>("Font/Font");
            int gap              = 0;
            int horizontalpading = 0;

            var lvl1 = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(graphics.Viewport.Width / 38 + horizontalpading, 300 + gap),
                Text     = "Level 1",
            };

            lvl1.Click += LVL1_Clicked;

            var lvl2 = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(graphics.Viewport.Width / 38 + horizontalpading, 450 + gap),
                Text     = "Level 2",
            };

            lvl2.Click += LVL2_Clicked;

            var lvl3 = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(graphics.Viewport.Width / 38 + horizontalpading, 600 + gap),
                Text     = "Level 3",
            };

            lvl3.Click += LVL3_Clicked;

            var lvl4 = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(graphics.Viewport.Width / 38 + horizontalpading, 750 + gap),
                Text     = "Level 4",
            };

            lvl4.Click += LVL4_Clicked;

            components = new List <Component>()
            {
                lvl1,
                lvl2,
                lvl3,
                lvl4,
            };
        }