コード例 #1
0
ファイル: Game1.cs プロジェクト: urvaius/InvaderX
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //this is code to add a generic menu etc. using our MenuComponent class

            // string[] menuItems = { "Start Game", "High Scores", "End Game" };

            startScreen = new StartScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("menuimage"));
            Components.Add(startScreen);
            startScreen.Hide();

            actionScreen = new ActionScreen(this, spriteBatch, Content.Load<Texture2D>("nebula1"),Content.Load<Texture2D>("ship/ship1"),graphics);
            Components.Add(actionScreen);
            actionScreen.Hide();
            activeScreen = startScreen;
            activeScreen.Show();

            //   menuComponent = new MenuComponent(this, spriteBatch, Content.Load<SpriteFont>("menufont"), menuItems);
            //Components.Add(menuComponent);

            // TODO: use this.Content to load your game content here
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: urvaius/InvaderX
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit

            keyboardState = Keyboard.GetState();
            gamePadState = GamePad.GetState(PlayerIndex.One);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (activeScreen == startScreen)
            {
                if (CheckKey(Keys.Enter) || CheckButton(Buttons.A))
                {
                    if (startScreen.SelectedIndex == 0)
                    {
                        activeScreen.Hide();
                        activeScreen = actionScreen;
                        activeScreen.Show();

                    }
                    if (startScreen.SelectedIndex == 1)
                    {
                        this.Exit();
                    }
                }
            }
            base.Update(gameTime);
            oldKeyBoardState = keyboardState;
            oldGamePadState = gamePadState;
        }