JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Scene.hpp
Go to the documentation of this file.
1// Copyright 2025 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include "work.hpp"
8
9namespace jngl {
10
13using Scene = Work;
14
17 return getWork();
18}
19
22
24template <class T, class... Args> T& setScene(Args&&... args) {
25 auto shared = std::make_shared<T>(std::forward<Args>(args)...);
26 auto& rtn = *shared;
27 setScene(std::move(shared));
28 return rtn;
29}
30
36
37} // namespace jngl
Active state of the game, e.g. a menu or the game itself.
Definition work.hpp:13
JNGL's main namespace.
std::shared_ptr< Scene > getActiveScene()
Returns the currently active Scene.
Definition Scene.hpp:16
std::shared_ptr< Work > getWork()
Returns the current active Work or nullptr if none has been set.
void setScene(std::shared_ptr< Scene >)
Sets the passed Scene to be active in the main loop for the next frame.
std::shared_ptr< Scene > getNextScene()
Returns the Scene that will be active in the next frame.