/// <summary>
 /// Responds to user input, accepting or cancelling the message box.
 /// </summary>
 public override void HandleInput(InputHelper input, GameTime gameTime)
 {
     if (input.IsMenuSelect() || input.IsMenuCancel() ||
         input.IsNewMouseButtonPress(MouseButtons.LeftButton))
     {
         ExitScreen();
     }
 }
 public override void HandleInput(InputHelper input, GameTime gameTime)
 {
     if (input.KeyboardState.GetPressedKeys().Length > 0 ||
         input.GamePadState.IsButtonDown(Buttons.A | Buttons.Start | Buttons.Back) ||
         input.MouseState.LeftButton == ButtonState.Pressed)
     {
         _duration = TimeSpan.Zero;
     }
 }
 public void HandleInput(InputHelper input)
 {
     //if (!this.IsTracking)
         //{
         //    for (int i = 0; i < input.TouchState.Count; i++)
         //    {
         //        if (input.TouchState[i].State == TouchLocationState.Pressed)
         //        {
         //            this.Velocity = Vector2.Zero;
         //            this.UnclampedViewOrigin = this.ViewOrigin;
         //            this.IsTracking = true;
         //            break;
         //        }
         //    }
         //}
         //using (List<GestureSample>.Enumerator enumerator = input.Gestures.GetEnumerator())
         //{
         //    while (enumerator.MoveNext())
         //    {
         //        GestureSample current = enumerator.Current;
         //        GestureType gestureType = current.GestureType;
         //        if (gestureType <= GestureType.VerticalDrag)
         //        {
         //            if (gestureType != GestureType.Tap)
         //            {
         //                if (gestureType == GestureType.VerticalDrag)
         //                {
         //                    this.UnclampedViewOrigin.Y = this.UnclampedViewOrigin.Y - current.Delta.Y;
         //                }
         //            }
         //        }
         //        else
         //        {
         //            if (gestureType != GestureType.Flick)
         //            {
         //                if (gestureType == GestureType.DragComplete)
         //                {
         //                    this.IsTracking = false;
         //                }
         //            }
         //            else
         //            {
         //                if (Math.Abs(current.Delta.X) < Math.Abs(current.Delta.Y))
         //                {
         //                    this.IsTracking = false;
         //                    this.Velocity = -current.Delta;
         //                }
         //            }
         //        }
         //    }
         //}
 }
        /// <summary>
        /// Constructs a new screen manager component.
        /// </summary>
        public ScreenManager(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // we must set EnabledGestures before we can query for them, but
            // we don't assume the game wants to read them.
            TouchPanel.EnabledGestures = GestureType.None;
            _contentManager = game.Content;
            _contentManager.RootDirectory = "Content";
            _input = new InputHelper(this);

            _screens = new List<GameScreen>();
            _screensToUpdate = new List<GameScreen>();
            _transitions = new List<RenderTarget2D>();
        }
 public virtual void HandleInput(InputHelper input)
 {
     for (int i = 0; i < this.ChildCount; i++)
     {
         this.children[i].HandleInput(input);
     }
 }
Ejemplo n.º 6
0
 public override void HandleInput(InputHelper input, GameTime gameTime)
 {
     _pnlMenu.HandleInput(input);
     base.HandleInput(input, gameTime);
 }
Ejemplo n.º 7
0
 public void Input(InputHelper input)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputHelper input, GameTime gameTime)
 {
 }
 public override void HandleInput(InputHelper input)
 {
     this.scrollTracker.HandleInput(input);
         base.HandleInput(input);
 }
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputHelper input, GameTime gameTime)
        {
            // Mouse or touch on a menu item
            int hoverIndex = GetMenuEntryAt(input.Cursor);
            if (hoverIndex > -1 && _menuEntries[hoverIndex].IsSelectable() && !_scrollLock)
            {
                _selectedEntry = hoverIndex;
            }
            else
            {
                _selectedEntry = -1;
            }

            _scrollSlider.Hover = false;
            if (input.IsCursorValid)
            {
                _scrollUp.Collide(input.Cursor);
                _scrollDown.Collide(input.Cursor);
                _scrollSlider.Collide(input.Cursor);
            }
            else
            {
                _scrollUp.Hover = false;
                _scrollDown.Hover = false;
                _scrollLock = false;
            }

            // Accept or cancel the menu?
            if (input.IsMenuSelect() && _selectedEntry != -1)
            {
                if (_menuEntries[_selectedEntry].IsExitItem())
                {
                    ScreenManager.Game.Exit();
                }
                else if (_menuEntries[_selectedEntry].Screen != null)
                {
                    ScreenManager.AddScreen(_menuEntries[_selectedEntry].Screen);
                    if (_menuEntries[_selectedEntry].Screen is IDemoScreen)
                    {
                        ScreenManager.AddScreen(
                            new MessageBoxScreen((_menuEntries[_selectedEntry].Screen as IDemoScreen).GetDetails()));
                    }
                }
            }
            else if (input.IsMenuCancel())
            {
                ScreenManager.Game.Exit();
            }

            if (input.IsMenuPressed())
            {
                if (_scrollUp.Hover)
                {
                    _menuOffset = Math.Max(_menuOffset - 200f * (float)gameTime.ElapsedGameTime.TotalSeconds, 0f);
                    _scrollLock = false;
                }
                if (_scrollDown.Hover)
                {
                    _menuOffset = Math.Min(_menuOffset + 200f * (float)gameTime.ElapsedGameTime.TotalSeconds, _maxOffset);
                    _scrollLock = false;
                }
                if (_scrollSlider.Hover)
                {
                    _scrollLock = true;
                }
            }
            if (input.IsMenuReleased())
            {
                _scrollLock = false;
            }
            if (_scrollLock)
            {
                _scrollSlider.Hover = true;
                _menuOffset = Math.Max(Math.Min(((input.Cursor.Y - _menuBorderTop) / (_menuBorderBottom - _menuBorderTop)) * _maxOffset, _maxOffset), 0f);
            }
        }
        public override void HandleInput(InputHelper input, GameTime gameTime)
        {
            //MouseState mouse = input.MouseState;
            //int tp = mouse.ScrollWheelValue/100;
            //Camera.Zoom = tp < 1 ? 1 : tp;
            //KeyboardState keyBoard = input.KeyboardState;
            //int x = 0, y = 0;
            //if (keyBoard.IsKeyDown(Keys.A))
            //{
            //    x -= 40;
            //}
            //if (keyBoard.IsKeyDown(Keys.W))
            //{
            //    y -= 20;
            //}
            //if (keyBoard.IsKeyDown(Keys.S))
            //{
            //    y += 20;
            //}
            //if (keyBoard.IsKeyDown(Keys.D))
            //{
            //    x += 40;
            //}

            //if (x != 0 || y != 0)
            //{
            //    heroBird.Body.ApplyForce(new Vector2(x, y));
            //}

            //if (input.IsNewKeyPress(Keys.Space))
            //{
            //    heroBird.Body.ApplyLinearImpulse(new Vector2(0f, -20f));
            //}
            base.HandleInput(input, gameTime);
        }