MoveCamera() public méthode

public MoveCamera ( Vector2 amount ) : void
amount Vector2
Résultat void
        private void HandleCamera(InputHelper input, GameTime gameTime)
        {
            Vector2 camMove = Vector2.Zero;

            if (input.GamePadState.IsButtonDown(Buttons.RightShoulder))
            {
                camMove = input.GamePadState.ThumbSticks.Right * new Vector2(10f, -10f) * (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (input.GamePadState.IsButtonDown(Buttons.RightTrigger))
                {
                    Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
                }

                if (input.GamePadState.IsButtonDown(Buttons.LeftTrigger))
                {
                    Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
                }

                if (input.IsNewButtonPress(Buttons.X))
                {
                    Camera.ResetCamera();
                }
            }
            else
            {
                if (input.KeyboardState.IsKeyDown(Keys.Up))
                {
                    camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                if (input.KeyboardState.IsKeyDown(Keys.Down))
                {
                    camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                if (input.KeyboardState.IsKeyDown(Keys.Left))
                {
                    camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                if (input.KeyboardState.IsKeyDown(Keys.Right))
                {
                    camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                if (input.KeyboardState.IsKeyDown(Keys.PageUp))
                {
                    Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
                }
                if (input.KeyboardState.IsKeyDown(Keys.PageDown))
                {
                    Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
                }
                if (input.IsNewKeyPress(Keys.Home))
                {
                    Camera.ResetCamera();
                }
            }

            if (camMove != Vector2.Zero)
            {
                Camera.MoveCamera(camMove);
            }
        }
Exemple #2
0
        private void HandleCamera(InputHelper input, GameTime gameTime)
        {
            Vector2 camMove = Vector2.Zero;

            if (input.KeyboardState.IsKeyDown(Keys.Up))
            {
                camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.Down))
            {
                camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.Left))
            {
                camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.Right))
            {
                camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.PageUp))
            {
                Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
            }
            if (input.KeyboardState.IsKeyDown(Keys.PageDown))
            {
                Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
            }
            if (camMove != Vector2.Zero)
            {
                Camera.MoveCamera(camMove);
            }
            if (input.IsNewKeyPress(Keys.Home))
            {
                Camera.ResetCamera();
            }
        }