![]() |
xyginext
0.2.0
Second generation of xygine game creation framework
|
Abstract base class for xygine states. More...
#include <State.hpp>
Classes | |
struct | Context |
Contains information about the current application context. More... | |
Public Types | |
using | Ptr = std::unique_ptr< State > |
Public Member Functions | |
State (StateStack &stateStack, Context context) | |
Constructor. More... | |
State (const State &)=delete | |
State (State &&)=delete | |
State & | operator= (const State &)=delete |
State & | operator= (State &&)=delete |
virtual bool | handleEvent (const sf::Event &evt)=0 |
Receives window events from the state stack to which the state belongs. More... | |
virtual void | handleMessage (const Message &)=0 |
Receives system messages from the message bus via the state stack to which the state belongs. More... | |
virtual bool | update (float dt)=0 |
Passes in the frame time once per frame. More... | |
virtual void | draw ()=0 |
Function to handle drawing. More... | |
virtual StateID | stateID () const =0 |
Returns the unique ID of this state. | |
void | setContext (Context) |
Applies a new context for this state. More... | |
Protected Member Functions | |
void | requestStackPush (StateID id) |
Request a new instance of a state with the given ID be pushed on top of the state stack to which this state belongs. More... | |
void | requestStackPop () |
Request that the state on top of the stack to which this state belongs is popped (and therefore destroyed) | |
void | requestStackClear () |
Request that all active states in the stack to which this state belongs are destroyed. | |
std::size_t | getStackSize () const |
Returns the current number of states on the active state stack. | |
Context | getContext () const |
Returns a copy of the state's current context. | |
void | launchLoadingScreen () |
void | quitLoadingScreen () |
virtual void | updateLoadingScreen (float dt, sf::RenderWindow &) |
std::size_t | getStateCount () const |
Returns the number of active states on this state's stack. | |
Abstract base class for xygine states.
States are used in conjunction with the StateStack to encapsulate the data required to display different states such as the main menu, pause screen, or game state
xy::State::State | ( | StateStack & | stateStack, |
Context | context | ||
) |
Constructor.
stateStack | State stack to which this state should be added |
context | The app's current context |
|
pure virtual |
Function to handle drawing.
The App derived class should handle the clear() and display() functions outside of the state stack to which this state belongs so any drawing can be done here via getContext().renderWindow
|
pure virtual |
Receives window events from the state stack to which the state belongs.
|
pure virtual |
Receives system messages from the message bus via the state stack to which the state belongs.
Messages can either be handle here, passed on to state members (such as a Scene) or both.
|
protected |
Optionally call these at the beginning and end of a state ctor which loads a lot of resources. Main game updates are suspended so you MUST call quitLoadingScreen() when finished.
|
protected |
Request a new instance of a state with the given ID be pushed on top of the state stack to which this state belongs.
id | StateID of state to be pushed on to the stack |
void xy::State::setContext | ( | Context | ) |
Applies a new context for this state.
Used by xygine to update the default view should the render window be resized or toggled between full screen
|
pure virtual |
Passes in the frame time once per frame.
Members of the state such as a Scene object can be updated here.
|
protectedvirtual |
Optionally overload this to draw custom graphics during loading. As this runs in its own thread SYNCHRONISATION IS UP TO YOU.