Camera2DScreenSpace ClassDelta Engine Documentation
Behaves like QuadraticScreenSpace but can also pan and zoom. See https://deltaengine.fogbugz.com/default.asp?W101 View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.ScreenSpaces ScreenSpace
    DeltaEngine.ScreenSpaces QuadraticScreenSpace
      DeltaEngine.ScreenSpaces Camera2DScreenSpace

Namespace: DeltaEngine.ScreenSpaces
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class Camera2DScreenSpace : QuadraticScreenSpace

The Camera2DScreenSpace type exposes the following members.

Constructors

  NameDescription
Public methodCamera2DScreenSpace
Initializes a new instance of the Camera2DScreenSpace class
Top
Methods

  NameDescription
Public methodDispose (Inherited from ScreenSpace.)
Public methodFromPixelSpace(Rectangle) (Inherited from ScreenSpace.)
Public methodFromPixelSpace(Size) (Overrides QuadraticScreenSpace FromPixelSpace(Size).)
Public methodFromPixelSpace(Vector2D) (Overrides QuadraticScreenSpace FromPixelSpace(Vector2D).)
Public methodGetInnerPosition (Inherited from QuadraticScreenSpace.)
Public methodInverseTransform
Protected methodRaiseViewportSizeChanged (Inherited from ScreenSpace.)
Public methodToPixelSpace(Rectangle) (Inherited from ScreenSpace.)
Public methodToPixelSpace(Size) (Overrides QuadraticScreenSpace ToPixelSpace(Size).)
Public methodToPixelSpace(Vector2D) (Overrides QuadraticScreenSpace ToPixelSpace(Vector2D).)
Public methodToPixelSpaceRounded
The rounded version of ToPixelSpace is used for lines, boxes and fonts where it matters to actually render at exact pixel positions to get sharp lines, boxes or font rendering. View code on GitHub
(Inherited from ScreenSpace.)
Public methodTransform
Protected methodUpdate (Inherited from QuadraticScreenSpace.)
Top
Fields

  NameDescription
Public fieldLookAt
Public fieldRotation
Public fieldRotationCenter
Protected fieldviewportPixelSize (Inherited from ScreenSpace.)
Top
Properties

  NameDescription
Public propertyAspectRatio (Inherited from ScreenSpace.)
Public propertyBottom (Overrides QuadraticScreenSpace Bottom.)
Public propertyBottomRight (Overrides QuadraticScreenSpace BottomRight.)
Public propertyLeft (Overrides QuadraticScreenSpace Left.)
Public propertyRight (Overrides QuadraticScreenSpace Right.)
Public propertyTop (Overrides QuadraticScreenSpace Top.)
Public propertyTopLeft (Overrides QuadraticScreenSpace TopLeft.)
Public propertyViewport (Inherited from ScreenSpace.)
Public propertyZoom
Top
Events

  NameDescription
Public eventViewportSizeChanged (Inherited from ScreenSpace.)
Top
Remarks

Tests: DeltaEngine.Tests.ScreenSpaces.Camera2DScreenSpaceTests
Examples

11 unit tests call DeltaEngine.ScreenSpaces.Camera2DScreenSpace
[Test]
public void LookAt()
{
    var camera = new Camera2DScreenSpace(window);
    Assert.AreEqual(Vector2D.Half, camera.LookAt);
    camera.LookAt = Vector2D.One;
    Assert.AreEqual(Vector2D.One, camera.LookAt);
}
[Test]
public void Zoom()
{
    var camera = new Camera2DScreenSpace(window);
    Assert.AreEqual(1.0f, camera.Zoom);
    camera.Zoom = 2.5f;
    Assert.AreEqual(2.5f, camera.Zoom);
}
[Test]
public void IfCameraNotAdjustedItBehavesIdenticallyToQuadraticScreenSpace()
{
    var q = new QuadraticScreenSpace(window);
    var c = new Camera2DScreenSpace(window);
    Assert.IsTrue(
        c.FromPixelSpace(new Vector2D(1, 2)).IsNearlyEqual(q.FromPixelSpace(new Vector2D(1, 2))));
    Assert.IsTrue(
        c.FromPixelSpace(new Size(-3, 4)).IsNearlyEqual(q.FromPixelSpace(new Size(-3, 4))));
    Assert.IsTrue(
        c.ToPixelSpace(new Vector2D(2, 6)).IsNearlyEqual(q.ToPixelSpace(new Vector2D(2, 6))));
    Assert.IsTrue(c.ToPixelSpace(new Size(-2, 0)).IsNearlyEqual(q.ToPixelSpace(new Size(-2, 0))));
}
See Also