xyginext  0.2.0
Second generation of xygine game creation framework
Public Types | Public Member Functions | Friends | List of all members
xy::Camera Class Referencefinal

Represents a 2D camera. Camera components can be attached to entities so that they take on the transform of any transform component, and also be used to bound the game world view. More...

#include <Camera.hpp>

Public Types

enum  Axis { X, Y, None }
 

Public Member Functions

void setView (sf::Vector2f)
 Sets the visible area, in world units, of the camera. This defaults to the size of the window.
 
void setViewport (sf::FloatRect)
 Sets the normalised viewport (0.f - 1.f) of this camera. The viewport represents the percentage of the render target which is rendered to. More...
 
void lockAxis (Axis, float)
 Locks the camera movement along a certain axis. For example locking the Y axis will allow the camera to follow a character as it travels left and right, but will not move vertically when the character jumps. More...
 
void lockRotation (bool)
 
void setBounds (sf::FloatRect)
 Locks the camera movement within the given bounds. For example if this is set to the size of the game map the camera will stop at the edges preventing the 'outside' from being visible.
 
void zoom (float)
 Multiplies the current zoom level. Contrary to default SFML views a value of 2 will make the scene appear 2x larger, and a value of less than 1 will zoom out. Values must be greater than 0.
 
void setZoom (float)
 Sets the zoom level relative to the current view size. Setting this to 2x when the view size is 320x240, for example will display an area 160x120 units in size. Must be greater than 0.
 
sf::Vector2f getView () const
 Returns the current view of the camera, in world units. This is the pre-zoomed value, or the view with a zoom of 1x.
 
sf::FloatRect getViewport () const
 Returns the current viewport.
 
Axis getLockedAxis () const
 Returns which axis is currently locked.
 
bool rotationLocked () const
 Returns true if rotation is locked, else returns false.
 
sf::FloatRect getBounds () const
 Returns the current bounds of the camera.
 
float getZoom () const
 Returns the current zoom level. Default is 1x.
 

Friends

class Scene
 
class CameraSystem
 

Detailed Description

Represents a 2D camera. Camera components can be attached to entities so that they take on the transform of any transform component, and also be used to bound the game world view.

Member Function Documentation

◆ lockAxis()

void xy::Camera::lockAxis ( Axis  ,
float   
)

Locks the camera movement along a certain axis. For example locking the Y axis will allow the camera to follow a character as it travels left and right, but will not move vertically when the character jumps.

Parameters
axisWhich axis to lock, or None to unlock
floatValue at which to lock the given axis. EG lockAxis(Y, 100.f) will lock the camera's vertical postion to 100 world units.

◆ setViewport()

void xy::Camera::setViewport ( sf::FloatRect  )

Sets the normalised viewport (0.f - 1.f) of this camera. The viewport represents the percentage of the render target which is rendered to.

See also
sf::View::setViewport()