예제 #1
0
 public Camera()
 {
     position = Vector2.Zero;
     zoom = 1.0f;
     transformMatrixDirty = true;
     motionState = CameraMotionState.Fixed;
 }
예제 #2
0
 public Camera()
 {
     position             = Vector2.Zero;
     zoom                 = 1.0f;
     transformMatrixDirty = true;
     motionState          = CameraMotionState.Fixed;
 }
예제 #3
0
        /// <summary>
        /// Pans the camera to a specified point in the world with a given duration.
        /// </summary>
        /// <param name="target">The target point in world space.</param>
        /// <param name="duration">How long the pan should take.</param>
        public void PanTo(Vector2 target, TimeSpan duration)
        {
            panOrigin = Position;
            panTarget = target;

            panDuration = duration;
            panTimeLeft = duration;

            motionState = CameraMotionState.Panning;
        }
예제 #4
0
 /// <summary>
 /// Moves the camera immediately to the end of the current pan.
 /// </summary>
 public void CancelPan()
 {
     if (motionState == CameraMotionState.Panning)
     {
         Position    = panTarget;
         motionState = CameraMotionState.Fixed;
         if (PanCompleted != null)
         {
             PanCompleted();
         }
     }
 }
예제 #5
0
 public void Update(GameTime gameTime)
 {
     // Update panning motion
     if (motionState == CameraMotionState.Panning)
     {
         panTimeLeft -= gameTime.ElapsedGameTime;
         if (panTimeLeft < TimeSpan.Zero)
         {
             panTimeLeft = TimeSpan.Zero;
             motionState = CameraMotionState.Fixed;
             Position    = panTarget;
             if (PanCompleted != null)
             {
                 PanCompleted();
             }
         }
         else
         {
             double panPercentage = (panDuration.TotalMilliseconds - panTimeLeft.TotalMilliseconds) / panDuration.TotalMilliseconds;
             Position = Vector2.SmoothStep(panOrigin, panTarget, (float)panPercentage);
         }
     }
 }
예제 #6
0
 /// <summary>
 /// Moves the camera immediately to the end of the current pan.
 /// </summary>
 public void CancelPan()
 {
     if (motionState == CameraMotionState.Panning)
     {
         Position = panTarget;
         motionState = CameraMotionState.Fixed;
         if (PanCompleted != null)
         {
             PanCompleted();
         }
     }
 }
예제 #7
0
 public void Update(GameTime gameTime)
 {
     // Update panning motion
     if (motionState == CameraMotionState.Panning)
     {
         panTimeLeft -= gameTime.ElapsedGameTime;
         if (panTimeLeft < TimeSpan.Zero)
         {
             panTimeLeft = TimeSpan.Zero;
             motionState = CameraMotionState.Fixed;
             Position = panTarget;
             if (PanCompleted != null)
             {
                 PanCompleted();
             }
         }
         else
         {
             double panPercentage = (panDuration.TotalMilliseconds - panTimeLeft.TotalMilliseconds) / panDuration.TotalMilliseconds;
             Position = Vector2.SmoothStep(panOrigin, panTarget, (float)panPercentage);
         }
     }
 }
예제 #8
0
        /// <summary>
        /// Pans the camera to a specified point in the world with a given duration.
        /// </summary>
        /// <param name="target">The target point in world space.</param>
        /// <param name="duration">How long the pan should take.</param>
        public void PanTo(Vector2 target, TimeSpan duration)
        {
            panOrigin = Position;
            panTarget = target;

            panDuration = duration;
            panTimeLeft = duration;

            motionState = CameraMotionState.Panning;
        }