NasNas
An intuitive and beginner friendly 2D game framework for C++
|
Public Member Functions | |
Camera (std::string name, int render_order) | |
Construct a Camera object. More... | |
Camera (const Camera &)=delete | |
Camera (Camera &&)=default | |
Camera & | operator= (const Camera &)=delete |
Camera & | operator= (Camera &&)=default |
void | reset (int x, int y, int w, int h) |
Reset Camera size and position. More... | |
void | reset (const sf::Vector2i &position, const sf::Vector2i &size) |
Reset Camera size and position. More... | |
void | reset (const ns::IntRect &rect) |
Reset Camera size and position. More... | |
void | resetViewport (float x, float y, float w, float h) |
Reset Camera viewport. More... | |
void | resetViewport (const sf::Vector2f &position, const sf::Vector2f &size) |
Reset Camera viewport. More... | |
void | resetViewport (const sf::FloatRect &rect) |
Reset Camera viewport. More... | |
auto | getViewport () const -> const ns::FloatRect & |
auto | hasScene () -> bool |
Is the Camera looking at a Scene ? More... | |
void | lookAt (Scene &scene) |
Tell the Camera to look at a Scene. More... | |
auto | isVisible () const -> bool |
Is the Camera visible ? More... | |
void | setVisible (bool value) |
Show or hide the Camera content. More... | |
void | follow (sf::Transformable &transformable) |
Follow an entity, Camera position will be updated accordingly automatically. More... | |
void | unfollow () |
auto | getRenderOrder () const -> int |
Get render order of the Camera. More... | |
auto | getFramesDelay () const -> unsigned int |
void | setFramesDelay (unsigned int value) |
Set the frame delay. More... | |
void | setLimitsRect (const ns::IntRect &rectangle) |
Sets Camera move limits. More... | |
auto | getPosition () const -> sf::Vector2f |
Get Camera position in world's coordinates. More... | |
auto | getFolloweePosition () const -> const sf::Vector2f & |
auto | getLeft () const -> float |
Get Camera left position in world's coordinates. More... | |
void | setLeft (float value) |
Set Camera left position in world's coordinates. More... | |
auto | getRight () const -> float |
Get Camera right position in world's coordinates. More... | |
void | setRight (float value) |
Set Camera right position in world's coordinates. More... | |
auto | getTop () const -> float |
Get Camera top position in world's coordinates. More... | |
void | setTop (float value) |
Set Camera top position in world's coordinates. More... | |
auto | getBottom () const -> float |
Get Camera bottom position in world's coordinates. More... | |
void | setBottom (float value) |
Set Camera bottom position in world's coordinates. More... | |
auto | getGlobalBounds () const -> ns::FloatRect |
Get camera global bounds. More... | |
void | update () |
Updates Camera position if following an entity. | |
![]() | |
void | setShader (sf::Shader *shader) |
Set the shader to be applied when rendering. More... | |
auto | getShader () const -> sf::Shader * |
Get the current Shader. More... | |
void | toggleShader () |
Toggle shader. | |
void | clearShader () |
Remove the shader. More... | |
Friends | |
class | App |
Definition at line 22 of file Camera.hpp.
ns::Camera::Camera | ( | std::string | name, |
int | render_order | ||
) |
void ns::Camera::follow | ( | sf::Transformable & | transformable | ) |
Follow an entity, Camera position will be updated accordingly automatically.
drawable | Drawable object to follow |
auto ns::Camera::getBottom | ( | ) | const -> float |
auto ns::Camera::getFramesDelay | ( | ) | const -> unsigned int |
Get delay in position update over the followed entity
auto ns::Camera::getGlobalBounds | ( | ) | const -> ns::FloatRect |
Get camera global bounds.
auto ns::Camera::getLeft | ( | ) | const -> float |
auto ns::Camera::getPosition | ( | ) | const -> sf::Vector2f |
auto ns::Camera::getRenderOrder | ( | ) | const -> int |
auto ns::Camera::getRight | ( | ) | const -> float |
auto ns::Camera::getTop | ( | ) | const -> float |
auto ns::Camera::hasScene | ( | ) | -> bool |
auto ns::Camera::isVisible | ( | ) | const -> bool |
void ns::Camera::lookAt | ( | Scene & | scene | ) |
void ns::Camera::reset | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Reset Camera size and position.
x | New X position |
y | New Y position |
w | New width |
h | New height |
void ns::Camera::reset | ( | const sf::Vector2i & | position, |
const sf::Vector2i & | size | ||
) |
Reset Camera size and position.
position | New position |
size | New size |
void ns::Camera::reset | ( | const ns::IntRect & | rect | ) |
Reset Camera size and position.
rect | New view rectangle {position, size} |
void ns::Camera::resetViewport | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Reset Camera viewport.
Viewport defines how much space Camera content should take on the window and where it is placed. Coordinates in percentage. e.g. : 0 = 0% of the window 0.5 = 50% of the window 1 = 100% of the window
x | New viewport X pos |
y | New viewport Y pos |
w | New viewport width |
h | New viewport height |
void ns::Camera::resetViewport | ( | const sf::Vector2f & | position, |
const sf::Vector2f & | size | ||
) |
Reset Camera viewport.
position | New viewport position |
size | New viewport size |
void ns::Camera::resetViewport | ( | const sf::FloatRect & | rect | ) |
Reset Camera viewport.
rect | New viewport |
void ns::Camera::setBottom | ( | float | value | ) |
Set Camera bottom position in world's coordinates.
value | New bottom boundary position |
void ns::Camera::setFramesDelay | ( | unsigned int | value | ) |
Set the frame delay.
A delay of N means the Camera will need N frames to go to the followed entity position. Allows smooth camera movements
value | Frame delay |
void ns::Camera::setLeft | ( | float | value | ) |
Set Camera left position in world's coordinates.
value | New left boundary position |
void ns::Camera::setLimitsRect | ( | const ns::IntRect & | rectangle | ) |
Sets Camera move limits.
rectangle | Limits rectangle |
void ns::Camera::setRight | ( | float | value | ) |
Set Camera right position in world's coordinates.
value | New right boundary position |
void ns::Camera::setTop | ( | float | value | ) |
Set Camera top position in world's coordinates.
value | New top boundary position |
void ns::Camera::setVisible | ( | bool | value | ) |
Show or hide the Camera content.
value |