LPCGame
A Simple 2d Game Engine
|
A camera to draw the scene in. More...
#include <camera.h>
Public Member Functions | |
void | SetFocus (std::shared_ptr< Entity > obj) |
void | Update () |
Update the camera's position to keep the object centered. | |
bool | InCamera (Rectf box) const |
void | Move (Vector2f v) |
void | Move (float deltaT) |
void | Pan (std::string name) |
std::string | Scene () |
void | SetBox (Rectf box) |
Rectf | Box () const |
Returns the camera's box. | |
void | SetSceneBox (Rectf box) |
Rectf | SceneBox () const |
Get the scene box. | |
Vector2f | Offset () const |
Vector2f | Centering () const |
Json::Value | Save () |
void | Load (Json::Value val) |
bool | operator== (const Camera &c) const |
Operators. | |
bool | operator!= (const Camera &c) const |
A camera to draw the scene in.
A simple camera that can be given a gameobject to focus on and follow, or can be moved manually
Vector2f Camera::Centering | ( | ) | const |
Get the offset needed to center the scene in the window
bool Camera::InCamera | ( | Rectf | box | ) | const |
Check if an Rect is in the camera
box | The box to check if it's in the camera |
void Camera::Load | ( | Json::Value | val | ) |
Load the camera configuration from a Json::Value
val | The Json::Value to load from |
void Camera::Move | ( | Vector2f | v | ) |
Move the camera by some Vector2 This is used for dragging the camera with the mouse
v | The distance to move the camera |
void Camera::Move | ( | float | deltaT | ) |
Move the camera taking into account some elapsed time deltaT This is used for pan animations
deltaT | The elapsed time |
Vector2f Camera::Offset | ( | ) | const |
Get the offset needed to apply to objects in the camera, this offset includes the centering offset and any offset added from moving the camera
void Camera::Pan | ( | std::string | name | ) |
Instruct the camera to play some pre-defined panning
name | The name of the animation to play, if name not found nothing will happen |
Json::Value Camera::Save | ( | ) |
Save the camera information to file
std::string Camera::Scene | ( | ) |
Get the active scene
void Camera::SetBox | ( | Rectf | box | ) |
Set the camera box equal to the Rect passed, a check is performed to make sure that the camera box isn't bigger than the scene box if no scene box is set no problem, the check is also done when setting a scene box
box | The rect to set the camera box too |
void Camera::SetFocus | ( | std::shared_ptr< Entity > | obj | ) |
Register the gameobject to focus on with the camera
obj | The object for the camera to follow/center on |
void Camera::SetSceneBox | ( | Rectf | box | ) |
Set the scene's box, a check is done to make sure the camera box isn't bigger than the scene's box
box | The box to set the scene box too |