/// <summary> /// Moves the Camera in a straight line to a point over a number of seconds /// </summary> /// <param name="target"><see cref="Graphics.IDrawable"/>Target to be moved to</param> /// <param name="time">Time in seconds</param> public void MoveTo(Graphics.IDrawable target, double time) { Vector2 targetpos = new Vector2(); targetpos.X = (target.Position.X - Camera.Bounds.Width / 2 + target.Area.Width / 2); targetpos.Y = (target.Position.Y - Camera.Bounds.Height / 2 + target.Area.Height / 2); var cmd = new CameraCommand(time, targetpos, false, Vector2.Zero); //Thanks to the wonders of references this keeps the target up to date cmd.spriteTarget = target; this.commands.Add(cmd); }
/// <summary> /// Centers Camera on Sprite /// </summary> /// <param name="target">IDrawable to be targeted</param> public void FocusOn(Graphics.IDrawable target) { Vector2 targetpos = new Vector2(); targetpos.X = (target.Position.X - Camera.Bounds.Width / 2 + target.Area.Width / 2); targetpos.Y = (target.Position.Y - Camera.Bounds.Height / 2 + target.Area.Height / 2); var cmd = new CameraCommand(INF_TIME, targetpos, true, targetpos); //Thanks to the wonders of references this keeps the target up to date cmd.spriteTarget = target; this.commands.Add(cmd); }