View

2D camera that defines what region is shown on screen

View defines a camera in the 2D scene.

This is a very powerful concept: you can scroll, rotate or zoom the entire scene without altering the way that your drawable objects are drawn.

A view is composed of a source rectangle, which defines what part of the 2D scene is shown, and a target viewport, which defines where the contents of the source rectangle will be displayed on the render target (window or texture).

The viewport allows to map the scene to a custom part of the render target, and can be used for split-screen or for displaying a minimap, for example. If the source rectangle has not the same size as the viewport, its contents will be stretched to fit in.

To apply a view, you have to assign it to the render target. Then, every objects drawn in this render target will be affected by the view until you use another view.

Constructors

this
this()
Undocumented in source.
this
this(FloatRect rectangle)
Undocumented in source.
this
this(sfView* sfview)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

move
void move(Vector2f offset)

Move the view relatively to its current position.

reset
void reset(FloatRect rectangle)

Reset the view to the given rectangle.

zoom
void zoom(float factor)

Resize the view rectangle relatively to its current size.

Properties

center
Vector2f center [@property setter]

The center of the view.

center
Vector2f center [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
dup
View dup [@property getter]

Performs a deep copy of the view.

rotation
float rotation [@property setter]

The orientation of the view, in degrees. The default rotation is 0 degrees.

rotation
float rotation [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
size
Vector2f size [@property setter]

The size of the view. The default size is (1, 1).

size
Vector2f size [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
viewport
FloatRect viewport [@property setter]

The target viewpoirt.

viewport
FloatRect viewport [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

sfPtr
sfView* sfPtr;
Undocumented in source.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan