GameCamera ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Entity
    CreepyTowers GameCamera

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

public class GameCamera : Entity

The GameCamera type exposes the following members.

Constructors

  NameDescription
Public methodGameCamera
Initializes a new instance of the GameCamera class
Top
Methods

  NameDescription
Public methodAdd T  (Inherited from Entity.)
Public methodAddTag (Inherited from Entity.)
Public methodClearTags (Inherited from Entity.)
Public methodContains T  (Inherited from Entity.)
Public methodContainsBehavior T  (Inherited from Entity.)
Public methodContainsTag (Inherited from Entity.)
Protected methodDeactivate (Inherited from Entity.)
Public methodDispose (Overrides Entity Dispose .)
Public methodGet T 
Gets a specific component, derived classes can return faster cached values (e.g. Entity2D) View code on GitHub
(Inherited from Entity.)
Protected methodGetActiveBehaviors (Inherited from Entity.)
Protected methodGetComponentsForSaving (Inherited from Entity.)
Public methodGetOrDefault T  (Inherited from Entity.)
Public methodGetTags (Inherited from Entity.)
Public methodMoveCameraByMouse
Public methodRemove T  (Inherited from Entity.)
Public methodRemoveTag (Inherited from Entity.)
Public methodResetPositionToDefault
Public methodResetToMinZoom
Public methodSet (Inherited from Entity.)
Public methodSetComponents (Inherited from Entity.)
Public methodStart T  (Inherited from Entity.)
Public methodStop T  (Inherited from Entity.)
Public methodToString (Inherited from Entity.)
Top
Fields

  NameDescription
Protected fieldcomponents (Inherited from Entity.)
Top
Properties

  NameDescription
Public propertyAllowedMovementRect
Public propertyIsActive (Inherited from Entity.)
Public propertyIsPauseable (Inherited from Entity.)
Public propertyMaximumTurnAngle
Public propertyMaxZoom
Public propertyMinZoom
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyPosition
Public propertyRotationPerSecond
Public propertyUpdatePriority (Inherited from Entity.)
Public propertyZoomLevel
Public propertyZoomSmoothFactor
Top
Remarks

Tests: CreepyTowers.Tests.GameCameraTests
Examples

7 unit tests call CreepyTowers.GameCamera
[Test]
public void RenderCubeUsingGameCamera()
{
    var cubeMesh = new BoxMesh(Vector3D.One, Color.DarkGreen);
    new Model(new ModelData(cubeMesh), new Vector3D(0.0f, 0.0f, 0.0f));
    new Line3D(2 * Vector3D.UnitX, -3 * Vector3D.UnitY, Color.Red);
}
[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 MouseZoomWillZoomCamera()
{
    if (!IsMockResolver)
        return; //ncrunch: no coverage
    MockMouse mouse = (MockMouse)Resolve<Mouse>();
    var originalZoom = gameCamera.ZoomLevel;
    mouse.ScrollUp();
    AdvanceTimeAndUpdateEntities();
    Assert.AreNotEqual(originalZoom, gameCamera.ZoomLevel);
}
See Also