The 2D camera that renders the scene.
More...
#include <VCamera.h>
|
| VCamera () |
| The default constructor sets up the camera with a default view that is the size of the game's display.
|
|
| VCamera (sf::View &View) |
|
void | Follow (VObject *target, float deadzone=0.5f, CameraFollowMethod followmethod=LOCKON, float lead=0.0f, float lerp=0.0f) |
|
void | StopFollow () |
| Stop following a game object.
|
|
bool | Shake (float intensity, float time=1.0f, std::function< void()> OnComplete=nullptr) |
|
bool | Shake (sf::Vector2f intensity, float time=1.0f, std::function< void()> OnComplete=nullptr) |
|
bool | Fade (sf::Color colour=sf::Color::Black, float time=1.0f, bool fadein=false, std::function< void()> OnComplete=nullptr) |
|
bool | Flash (sf::Color colour=sf::Color::Black, float time=1.0f, std::function< void()> OnComplete=nullptr) |
|
void | SetToBounds (bool bound, sf::FloatRect bounderies=sf::FloatRect()) |
|
void | SetViewport (sf::FloatRect &viewport) |
|
void | Update (float dt) |
|
void | Render (sf::RenderTarget &RenderTarget) |
|
void | Reset () |
|
bool | IsFading () |
|
bool | IsFlashing () |
|
bool | IsShaking () |
|
sf::View const & | GetView () |
|
sf::View | GetDefaultView () |
|
|
sf::Vector2f | Position |
| The current position of the camera.
|
|
float | Rotation = 0.0f |
| The current angle of the camera.
|
|
float | Zoom = 1.0f |
| The current amount of zoom (default 1.0f) for the camera.
|
|
bool | Active = true |
| The camera is only used for rendering if Active is set to true.
|
|
The 2D camera that renders the scene.
◆ CameraFollowMethod
The method of how the camera shall follow a specific VObject.
Enumerator |
---|
LOCKON | Locks on directly to the VObject with no lerp or lead.
|
TOPDOWN | Locks onto the VObject with lerp and lead, best if a game has a top-down perspective.
|
PLATFORMER | Locks onto the VObject with lerp and lead, but with no dead zone restrictions for moving up. Best if a game is a side-scrolling platformer.
|
ROOM | Fixes to positions like a grid. best used for grid based levels where the screen size is evenly divisible to the world size.
|
ROOMLERP | Same as Room, however instead of instantly changing positions, the camera will lerp to the next position.
|
◆ VCamera()
VCamera::VCamera |
( |
sf::View & |
View | ) |
|
|
inline |
- Parameters
-
View | the sf::View that the Camera should use instead of the default one. |
◆ Fade()
bool VCamera::Fade |
( |
sf::Color |
colour = sf::Color::Black , |
|
|
float |
time = 1.0f , |
|
|
bool |
fadein = false , |
|
|
std::function< void()> |
OnComplete = nullptr |
|
) |
| |
Fade the screen the camera renders.
- Parameters
-
colour | The colour the camera should fade from/to. |
time | The length of time for the camera to fade. |
fadein | If true, the camera will fade from the colour to the screen. If false it will do the reverse, as if to fade out from the screen. |
OnComplete | A callback to call when the camera finishes fading. |
◆ Flash()
bool VCamera::Flash |
( |
sf::Color |
colour = sf::Color::Black , |
|
|
float |
time = 1.0f , |
|
|
std::function< void()> |
OnComplete = nullptr |
|
) |
| |
Flash the screen the camera renders.
- Parameters
-
colour | The colour the camera should flash to and from. |
time | The total length of time for the camera to flash. |
OnComplete | A callback to call when the camera finishes flashing. |
◆ Follow()
Set the camera to follow a specific VObject.
- Parameters
-
target | The object the camera must follow. |
deadzone | The dead zone area the camera should be restricted to. |
followmethod | The follow method that the camera should use. |
lead | The amount the camera should lead in front of the target. |
lerp | The amount the camera should lerp towards the target. |
◆ GetDefaultView()
sf::View VCamera::GetDefaultView |
( |
| ) |
|
- Returns
- The camera's current sf::View with default parameters.
◆ GetView()
sf::View const& VCamera::GetView |
( |
| ) |
|
|
inline |
- Returns
- The camera's current sf::View.
◆ IsFading()
bool VCamera::IsFading |
( |
| ) |
|
|
inline |
◆ IsFlashing()
bool VCamera::IsFlashing |
( |
| ) |
|
|
inline |
◆ IsShaking()
bool VCamera::IsShaking |
( |
| ) |
|
|
inline |
◆ Render()
void VCamera::Render |
( |
sf::RenderTarget & |
RenderTarget | ) |
|
Draws Camera for Flashing and Fading.
- Parameters
-
RenderTarget | the game's sf::RenderTarget object to render data onto. |
◆ Reset()
Resets camera properties to default.
◆ SetToBounds()
void VCamera::SetToBounds |
( |
bool |
bound, |
|
|
sf::FloatRect |
bounderies = sf::FloatRect() |
|
) |
| |
|
inline |
- Parameters
-
bound | If true, the game will bound to the defined world bounderies. |
bounderies | Custom bounderies to set the camera to, defaults to WorldBounds in VGlobal if none is set. |
◆ SetViewport()
void VCamera::SetViewport |
( |
sf::FloatRect & |
viewport | ) |
|
|
inline |
- Parameters
-
viewport | sets the camera's view to display from a specific section of the viewport (default is FloatRect(0, 0, 1, 1)). |
◆ Shake() [1/2]
bool VCamera::Shake |
( |
float |
intensity, |
|
|
float |
time = 1.0f , |
|
|
std::function< void()> |
OnComplete = nullptr |
|
) |
| |
Shake the camera.
- Parameters
-
intensity | The amount as a decimal percentage (multiplied by the camera's width and height) to shake by. |
time | The length of time for the camera to shake for. |
OnComplete | A callback to call when the camera finishes shaking. |
◆ Shake() [2/2]
bool VCamera::Shake |
( |
sf::Vector2f |
intensity, |
|
|
float |
time = 1.0f , |
|
|
std::function< void()> |
OnComplete = nullptr |
|
) |
| |
Shake the camera.
- Parameters
-
intensity | The amount as a decimal percentage (multiplied by the camera's width and height) to shake by. |
time | The length of time for the camera to shake for. |
OnComplete | A callback to call when the camera finishes shaking. |
◆ Update()
void VCamera::Update |
( |
float |
dt | ) |
|
Updates the camera's position, rotation and zoom.
- Parameters
-
dt | Delta Time between the current and previous frame in the game. |
The documentation for this class was generated from the following file:
- D:/Development/Libs/Vigilante-Game-Framework/VFrame/VCamera.h