JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Fade.hpp
Go to the documentation of this file.
1// Copyright 2025-2026 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 "Scene.hpp"
8
9#include <optional>
10
11namespace jngl {
12
15class Fade : public Scene {
16public:
17 struct Options {
18 int speed = 20;
19
21 bool fadeOutOnly = false;
22 };
23
25
30 std::optional<Options> options = {});
31
32 ~Fade() override;
33 void step() override;
34 void draw() const override;
35
36private:
37 void onQuitEvent() override;
38
41 double fadeCount;
42 int speed;
43 bool quit = false;
44 bool fadeOutOnly;
45};
46
47} // namespace jngl
Contains jngl::Scene class and related functions.
Fades between two scenes, first fading to jngl::getBackgroundColor() and then fading to the new scene...
Definition Fade.hpp:15
void draw() const override
Draw the game state.
Fade(std::function< std::shared_ptr< Scene >()> factory, std::optional< Options > options={})
Uses factory() to get the new Scene when the screen has faded to black (or the background color).
void onQuitEvent() override
Gets called when the user closes the main window or quit() has been called.
void step() override
Advance the game logic.
Active state of the game, e.g. a menu or the game itself.
Definition work.hpp:13
JNGL's main namespace.
bool fadeOutOnly
If true, only fades out and then immediately switches to the new scene.
Definition Fade.hpp:21