NasNas
An intuitive and beginner friendly 2D game framework for C++
Scene.hpp
1 
6 #pragma once
7 
8 #include <list>
9 #include <string>
10 
11 #include <SFML/Graphics/Drawable.hpp>
12 
13 #include <NasNas/core/data/Rect.hpp>
14 #include <NasNas/core/Layer.hpp>
15 
16 namespace ns {
17  class Camera;
18 
19  class Scene : public sf::Drawable {
20  friend class App;
21  friend Camera;
22  public:
32  explicit Scene(std::string name);
33 
34  Scene(const Scene&) = delete;
35  Scene(Scene&&) = default;
36  Scene& operator=(const Scene&) = delete;
37  Scene& operator=(Scene&&) = default;
38 
39  template <typename... T>
40  void createLayers(const T&... name) {
41  (m_layers.emplace_back(name), ...);
42  }
43 
49  void deleteLayer(const std::string& name);
50 
58  auto getLayer(const std::string& name) -> Layer&;
59 
66  auto getDefaultLayer() -> Layer&;
67 
68  private:
69  std::string m_name;
70  std::list<Layer> m_layers;
71  Layer m_default_layer;
72  ns::FloatRect m_render_bounds;
73 
79  void temporaryLinkCamera(Camera* camera);
80 
87  void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
88  };
89 
90 }
Scene(std::string name)
Constructs a Scene object.
auto getLayer(const std::string &name) -> Layer &
Returns the layer of the given name.
Definition: App.hpp:39
void deleteLayer(const std::string &name)
Removes and clears the Layer of the given name.
auto getDefaultLayer() -> Layer &
Returns the default Scene Layer Default layer will always be drawn first, before any other layer...