コード例 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Increments 1 and 2: draw appropriate items here

            // 4. Declare a Texture2D field in the Game1 class to hold the opening screen image. As usual, we’ll load
            //      content into this field then draw it as appropriate (Chapter 5, Week 2)
            // 8. In the Game1 Draw method, draw the opening screen texture in the opening screen draw rectangle
            //    (Chapter 5, Week 2)
            spriteBatch.Begin();

            // 10. In the Game1 Draw method, add an if statement that checks if the current game state is
            // GameState.Menu before drawing the opening screen texture in the opening screen draw rectangle
            // (Chapter 7, Week 3)
            // This step uses something called an enumeration, which we haven't discussed yet. You can read
            // about enumerations in Section 8.1 of the book if you'd like, but for this step you just need to know that
            // gameState == GameState.Menu
            // is a Boolean expression that will evaluate to true if the value of the gameState variable is currently
            // GameState.Menu.
            if (gameState == GameState.Menu)
            {
                spriteBatch.Draw(openingScreenImgText2D, drawRectangle, Color.White);
            }
            else
            {
                // 19. In the Game1 Draw method, add an else clause to the if statement from Step 10 to have the board draw
                //  itself if the current game state is GameState.Play
                //  (Chapter 7, Week 3)
                numberBoard.Draw(spriteBatch);
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            if (gameState == GameState.Menu)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(openingScreen, openingScreenDrawRectangle, Color.White);
                spriteBatch.End();
            }
            else if (gameState == GameState.Play)
            {
                numberBoard.Draw(spriteBatch);
            }

            base.Draw(gameTime);
        }
コード例 #3
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Increments 1 and 2: draw appropriate items here
            spriteBatch.Begin();
            if (gameState == GameState.Menu)
            {
                spriteBatch.Draw(openingScreenPng, openingScreenRectangle, Color.White);
            }
            else if (gameState == GameState.Play)
            {
                numberBoard.Draw(spriteBatch);
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Red);

            // Increments 1 and 2: draw appropriate items here
            if (gameState == GameState.Menu)
            {
                spriteBatch.Begin();

                spriteBatch.Draw(openingScreenTexture, openingScreenRec, Color.Green);

                spriteBatch.End();
            }
            else
            {
                numberBoard.Draw(spriteBatch);
            }

            base.Draw(gameTime);
        }