Exemple #1
0
        /// <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)
        {
            if (GamePadState.Buttons.Back == ButtonState.Pressed || KeyState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here

            // NOTE: You may want to disable player movement and other standard actions while the dialog box is displayed
            // or maybe not if you want it to just show up as the player is going along

            // Update the dialog box (essentially, process key/button input)
            _dialogBox.Update();

            // Debug key to show opening a new dialog box on demand
            if (Program.Game.KeyState.IsKeyDown(Keys.O))
            {
                if (!_dialogBox.Active)
                {
                    _dialogBox = new DialogBox {
                        Text = "New dialog box!"
                    };
                    _dialogBox.Initialize();
                }
            }

            // Update input states
            PreviousKeyState = KeyState;
            KeyState         = Keyboard.GetState();
            GamePadState     = GamePad.GetState(PlayerIndex.One);

            base.Update(gameTime);
        }
Exemple #2
0
        /// <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);

            // TODO: use this.Content to load your game content here

            // Don't forget to initialize your sprite font!
            DialogFont = Content.Load <SpriteFont>("dialog");

            // Build a new dialog box and give it some text
            _dialogBox = new DialogBox
            {
                Text = "Hello World! Press Enter or Button A to proceed.\n" +
                       "I will be on the next pane! " +
                       "And wordwrap will occur, especially if there are some longer words!\n" +
                       "Monospace fonts work best but you might not want Courier New.\n" +
                       "In this code sample, after this dialog box finishes, you can press the O key to open a new one."
            };

            // Initialize the dialog box (this also calls the Show() method)
            _dialogBox.Initialize();
        }
        /// <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);

            // TODO: use this.Content to load your game content here

            // Don't forget to initialize your sprite font!
            DialogFont = Content.Load<SpriteFont>("dialog");

            // Build a new dialog box and give it some text
            _dialogBox = new DialogBox
            {
                Text = "Hello World! Press Enter or Button A to proceed.\n" +
                       "I will be on the next pane! " +
                       "And wordwrap will occur, especially if there are some longer words!\n" +
                       "Monospace fonts work best but you might not want Courier New.\n" +
                       "In this code sample, after this dialog box finishes, you can press the O key to open a new one."
            };

            // Initialize the dialog box (this also calls the Show() method)
            _dialogBox.Initialize();
        }
        /// <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)
        {
            if (GamePadState.Buttons.Back == ButtonState.Pressed || KeyState.IsKeyDown(Keys.Escape))
                Exit();

            // TODO: Add your update logic here

            // NOTE: You may want to disable player movement and other standard actions while the dialog box is displayed
            // or maybe not if you want it to just show up as the player is going along

            // Update the dialog box (essentially, process key/button input)
            _dialogBox.Update();

            // Debug key to show opening a new dialog box on demand
            if (Program.Game.KeyState.IsKeyDown(Keys.O))
            {
                if (!_dialogBox.Active)
                {
                    _dialogBox = new DialogBox {Text = "New dialog box!"};
                    _dialogBox.Initialize();
                }
            }

            // Update input states
            PreviousKeyState = KeyState;
            KeyState = Keyboard.GetState();
            GamePadState = GamePad.GetState(PlayerIndex.One);

            base.Update(gameTime);
        }