class
DefaultGameModeA class that provides default implementation for all the methods in a IGameMode.
With this, one can create an IGameMode only implementing the necessary methods. It is recommended that if you implement the Initialize() method, you implement the Dispose() one as well. In the same way, OnEnter() should be paired with OnExit()
Base classes
- class IGameMode
- An interface that represents a mode in the game, that can receive mouse/keyboard input and update every frame.
Constructors, destructors, conversion operators
- DefaultGameMode()
- ~DefaultGameMode() virtual
Public functions
- auto AddRef() -> int override
- Increases the reference count and returns it.
- auto Release() -> int override
- Decreases the reference count and returns it.
- auto func0Ch() -> bool override
- auto Initialize(IGameModeManager* pManager) -> bool override
- This method is called once on every game mode when all modes have been added.
- auto Dispose() -> bool override
- This method is called once on every game mode when the game closes.
- auto OnEnter() -> bool override
- This method is called when the game mode is set as active, and therefore, entered.
- auto OnExit() -> void override
- This method is called when a different game mode is set as active, and therefore, this game mode is exited (no longer active).
- auto func20h(int) -> void* override
- auto OnKeyDown(int virtualKey, KeyModifiers modifiers) -> bool override
- An event listener called every time a key is pressed while this mode is active.
- auto OnKeyUp(int virtualKey, KeyModifiers modifiers) -> bool override
- An event listener called every time a key is released while this mode is active.
- auto OnMouseDown(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) -> bool override
- An event listener called every time a mouse key is pressed while this mode is active.
- auto OnMouseUp(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) -> bool override
- An event listener called every time a mouse key is released while this mode is active.
- auto OnMouseMove(float mouseX, float mouseY, MouseState mouseState) -> bool override
- An event listener called every time the mouse is moved while this mode is active.
- auto OnMouseWheel(int wheelDelta, float mouseX, float mouseY, MouseState mouseState) -> bool override
- An event listener called every time the mouse wheel is moved while this mode is active.
- auto Update(float delta1, float delta2) -> void override
- An event listener called every game loop.
Protected variables
Function documentation
bool App:: DefaultGameMode:: Initialize(IGameModeManager* pManager) override
This method is called once on every game mode when all modes have been added.
Parameters | |
---|---|
pManager | The GameModeManager that has called this method. |
This should take care of all initializations and setups that are required.
bool App:: DefaultGameMode:: OnKeyDown(int virtualKey,
KeyModifiers modifiers) override
An event listener called every time a key is pressed while this mode is active.
Parameters | |
---|---|
virtualKey | The VK code of the key. |
modifiers | The modifiers (Ctrl, Alt and Shift) currently being pressed. They use the enum values UTFWin::kModifier.... |
Returns | Whether the event was handled or not. |
bool App:: DefaultGameMode:: OnKeyUp(int virtualKey,
KeyModifiers modifiers) override
An event listener called every time a key is released while this mode is active.
Parameters | |
---|---|
virtualKey | The VK code of the key. |
modifiers | The modifiers (Ctrl, Alt and Shift) currently being pressed. They use the enum values UTFWin::kModifier.... |
Returns | Whether the event was handled or not. |
bool App:: DefaultGameMode:: OnMouseDown(MouseButton mouseButton,
float mouseX,
float mouseY,
MouseState mouseState) override
An event listener called every time a mouse key is pressed while this mode is active.
Parameters | |
---|---|
mouseButton | The button that was pressed. |
mouseX | The X position of the mouse. |
mouseY | The Y position of the mouse. |
mouseState | The state of the mouse. |
Returns | Whether the event was handled or not. |
bool App:: DefaultGameMode:: OnMouseUp(MouseButton mouseButton,
float mouseX,
float mouseY,
MouseState mouseState) override
An event listener called every time a mouse key is released while this mode is active.
Parameters | |
---|---|
mouseButton | The button that was released. |
mouseX | The X position of the mouse. |
mouseY | The Y position of the mouse. |
mouseState | The state of the mouse. |
Returns | Whether the event was handled or not. |
bool App:: DefaultGameMode:: OnMouseMove(float mouseX,
float mouseY,
MouseState mouseState) override
An event listener called every time the mouse is moved while this mode is active.
Parameters | |
---|---|
mouseX | The X position of the mouse. |
mouseY | The Y position of the mouse. |
mouseState | The state of the mouse. |
Returns | Whether the event was handled or not. |
bool App:: DefaultGameMode:: OnMouseWheel(int wheelDelta,
float mouseX,
float mouseY,
MouseState mouseState) override
An event listener called every time the mouse wheel is moved while this mode is active.
Parameters | |
---|---|
wheelDelta | The amount of units the wheel moved. This is a multiple of UTFWin::kMouseWheelDelta. |
mouseX | The X position of the mouse. |
mouseY | The Y position of the mouse. |
mouseState | The state of the mouse. |
Returns | Whether the event was handled or not. |