GameCamera Position Property Delta Engine Documentation

Namespace: CreepyTowers
Assembly: CreepyTowers (in CreepyTowers.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public Vector3D Position { get; set; }

Property Value

Type: Vector3D
Remarks

Tests: CreepyTowers.Tests.GameCameraTests
Examples

2 unit tests call CreepyTowers.GameCamera.Position
[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