Pure virtual State class, used as base class for Photon’s state system.
Photon’s State system is extremely simple yet also very convenient. Simply by creating classes that fulfill the State interface you can use Photon to manage the state that the game is in.
Implement as many or as few of the members of State as needed (the only necessary member being render) and make the state as current via Application::setState. Once a state is made current it’s update and render methods will be called every frame until either a new state is made current or the application ends.
The active state is also notified of events as they occur, overloading any of the on* functions will result in the overloaded version being called when the particular event happens while the state is active.
Summary
| Pure virtual State class, used as base class for Photon’s state system. |
| |
| |
| A State’s destructor is called whenever the state is no longer the active state (the application ends, or a new state is made active). |
| |
| All of a state’s logic should go in update, it is called every frame before the rendering process begins. |
| The only required member of State, anything that should be drawn to the screen while the State is active should be drawn in render. |
| If a state is executing and a new state is pushed onto the stack via Application::pushState the state will be paused until a time that it is either unpaused or popped from the stack itself. |
| If a state has been paused and is then made current again by the state(s) pushed on top of it being popped, the state management system will call onResume allowing the state to undo any work that had been done in onPause. |
| |
| Called when a key is pressed. |
| Called when a key is released. |
| |
| Called when a mouse button is pressed. |
| Called when a mouse button is released. |
| Called when the mouse is moved with the amount the mouse was moved by NOT with the new position. |
| Called when mouse wheel is scrolled. |