Namespace: CreepyTowers
Assembly: CreepyTowers (in CreepyTowers.exe) Version: 1.1.1.0 (1.1.1)
Tests: CreepyTowers.Tests.GameCameraTests
2 unit tests call CreepyTowers.GameCamera.Position
Assembly: CreepyTowers (in CreepyTowers.exe) Version: 1.1.1.0 (1.1.1)
Syntax
Property Value
Type: Vector3DRemarks
Examples
[Test, CloseAfterFirstFrame] public void MouseDragWillDragCamera() { if(!IsMockResolver) return; //ncrunch: no coverage MockMouse mouse = (MockMouse)Resolve<Mouse>(); var originalPosition = gameCamera.Position; bool dragInvoked = false; new Command("ViewPanning", () => dragInvoked = true); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopLeft + new Vector2D(0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressing); AdvanceTimeAndUpdateEntities(); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopRight + new Vector2D(-0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressed); AdvanceTimeAndUpdateEntities(); Assert.IsTrue(dragInvoked); Assert.AreNotEqual(originalPosition, gameCamera.Position); Assert.AreEqual(135.0f, (gameCamera.Position - originalPosition).Angle(Vector3D.UnitY)); }
[Test,CloseAfterFirstFrame] public void CameraCannotMoveOutOfItsRectangle() { gameCamera.AllowedMovementRect = Rectangle.Zero; var originalPosition = gameCamera.Position; if (!IsMockResolver) return; //ncrunch: no coverage MockMouse mouse = (MockMouse)Resolve<Mouse>(); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopLeft + new Vector2D(0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressing); AdvanceTimeAndUpdateEntities(); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopRight + new Vector2D(-0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressed); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(originalPosition, gameCamera.Position); }
See Also