JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
Fade Class Reference

Fades between two scenes, first fading to black and then fading to the new scene. More...

#include <jngl/Fade.hpp>

Public Member Functions

 Fade (std::shared_ptr< jngl::Work >, int speed=20)
 
void step () override
 Advance the game logic.
 
void draw () const override
 Draw the game state.
 
- Public Member Functions inherited from Work
virtual void onBackEvent ()
 Gets called on Android's "back" gesture or when the Esc key is pressed.
 
virtual void onControllerBack ()
 Gets called when the "Back" button is pressed on any connected controller (Android only)
 
virtual void onPauseEvent ()
 Gets called when the main window loses focus or the app is put in the background.
 
virtual void onLoad ()
 Gets called when the Work is activated by the main loop.
 
virtual void onUnload ()
 Gets called when the Work is deactivated by the main loop.
 
- Public Member Functions inherited from Job
virtual void onFileDrop (const std::filesystem::path &)
 Called when a file has been dropped onto the window.
 
virtual void onControllersChanged ()
 Whenever the return value of jngl::getConnectedControllers would change, this method gets called.
 
 Job ()=default
 Does nothing.
 
 Job (const Job &)=default
 Copy constructor.
 
Joboperator= (const Job &)=default
 Copy assignment.
 
 Job (Job &&)=default
 Move constructor.
 
Joboperator= (Job &&)=default
 Move assignment.
 
virtual ~Job ()
 Does nothing.
 

Private Member Functions

void onQuitEvent () override
 Gets called when the user closes the main window or quit() has been called.
 

Detailed Description

Fades between two scenes, first fading to black and then fading to the new scene.

Definition at line 12 of file Fade.hpp.

Inheritance diagram for Fade:
[legend]
Collaboration diagram for Fade:
[legend]

Member Function Documentation

◆ step()

void step ( )
overridevirtual

Advance the game logic.

This function gets called 60 times per second or whatever has been set by setStepsPerSecond().

Note
JNGL's main loop calls all Jobs' step() functions before the active Work's step()

Implements Job.

◆ draw()

void draw ( ) const
overridevirtual

Draw the game state.

As it isn't garuanteed that this function is called as often as Job::step, you shouldn't change any game state in it.

Note
JNGL's main loop calls all Jobs' draw() functions after the active Work's draw()

Implements Job.

◆ onQuitEvent()

void onQuitEvent ( )
overrideprivatevirtual

Gets called when the user closes the main window or quit() has been called.

To continue with the main loop, call cancelQuit(). For example if you want to switch to a pause menu instead of exiting the game:

class Game : public jngl::Work {
void onQuitEvent() {
jngl::setWork<PauseMenu>();
}
};
Active state of the game, e.g. a menu or the game itself.
Definition work.hpp:13
void cancelQuit()
Undo quit() or ignore a quit event caused by the user closing the main window.

Reimplemented from Work.


The documentation for this class was generated from the following file: