Пример #1
0
        private void UpdateCamera(GameTime gameTime, Vector3 posicao, Vector3 direcao)
        {
            // The chase camera's update behavior is the springs, but we can
            // use the Reset method to have a locked, spring-less camera
            if (cameraSpringEnabled)
            {
                camera.Update(gameTime);
            }
            else
            {
                camera.Reset();
            }

            //  Update the chase target
            camera.ChasePosition  = posicao;
            camera.ChaseDirection = direcao;

            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.S))
            {
                cameraSpringEnabled = !cameraSpringEnabled;
            }

            if (keyboard.IsKeyDown(Keys.PageUp))
            {
                camera.DesiredPositionOffset = new Vector3(0.0f, camera.DesiredPositionOffset.Y + 0.5f, camera.DesiredPositionOffset.Z + 0.5f);
            }

            if (keyboard.IsKeyDown(Keys.PageDown))
            {
                camera.DesiredPositionOffset = new Vector3(0.0f, camera.DesiredPositionOffset.Y - 0.5f, camera.DesiredPositionOffset.Z - 0.5f);
            }
        }
Пример #2
0
        public void InicializaCamera(GraphicsDevice device)
        {
            camera = new ChaseCamera();
            // Set the camera offsets
            camera.DesiredPositionOffset = new Vector3(0.0f, 2.0f, 3.0f);
            camera.LookAtOffset          = new Vector3(0.0f, 1.0f, 0.0f);
            // Set the camera aspect ratio
            camera.AspectRatio = (float)device.Viewport.Width / device.Viewport.Height;

            // Perform an inital reset on the camera so that it starts at the resting
            // position. If we don't do this, the camera will start at the origin and
            // race across the world to get behind the chased object.
            // This is performed here because the aspect ratio is needed by Reset.
            UpdateCamera(new GameTime(), player.position, player.direction);
            camera.Reset();
        }
Пример #3
0
        public void InicializaCamera(GraphicsDevice device)
        {
            camera = new ChaseCamera();
            // Set the camera offsets
            camera.DesiredPositionOffset = new Vector3(0.0f, 2.0f, 3.0f);
            camera.LookAtOffset = new Vector3(0.0f, 1.0f, 0.0f);
            // Set the camera aspect ratio
            camera.AspectRatio = (float)device.Viewport.Width / device.Viewport.Height;

            // Perform an inital reset on the camera so that it starts at the resting
            // position. If we don't do this, the camera will start at the origin and
            // race across the world to get behind the chased object.
            // This is performed here because the aspect ratio is needed by Reset.
            UpdateCamera(new GameTime(), player.position, player.direction);
            camera.Reset();
        }