Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
KatanaEngine::Screen Class Referenceabstract

Base class for all game screens and menus. More...

#include <Screen.h>

Inheritance diagram for KatanaEngine::Screen:

Public Member Functions

 Screen ()
 
virtual ~Screen ()
 
virtual void LoadContent (ResourceManager &resourceManager)
 Called when resources need to be loaded.
 
virtual void UnloadContent ()
 Called when resources need to be unloaded. Override this method to unload any screen-specific resources.
 
virtual void HandleInput (const InputState &input)
 Called when the game has determined that player input needs to be processed.
 
virtual void Update (const GameTime &gameTime)=0
 Called when the game has determined that screen logic needs to be processed.
 
virtual void Draw (SpriteBatch &spriteBatch)=0
 Called when the game determines it is time to draw a frame.
 
virtual bool IsExiting () const
 Determines if the screen is currently exiting.
 
float GetAlpha () const
 Gets the overall screen transition alpha value (or opacity). This is handy for fading screens in and out.
 
virtual ScreenManagerGetScreenManager ()
 Gets a pointer to the ScreenManager, for managing game screens.
 
virtual GameGetGame () const
 Gets a pointer to the Game.
 
virtual void SetScreenManager (ScreenManager &screenManager)
 Gets a pointer to the ScreenManager, for managing game screens.
 
virtual void Show ()
 Tells the screen to transition in.
 
virtual void Exit ()
 Tells the screen to transition out. When the screen has completed its transition, UnloadContent() will be called, and the ScreenManager will remove it.
 
virtual void SetExitCallback (OnExit callback)
 Sets the callback function for when the Exit() is called.
 
virtual void SetRemoveCallback (OnRemove callback)
 Sets the callback function for when the screen is about to be removed by the screen manager.
 
virtual double GetTransitionOutTime () const
 Get the time in seconds that the screen will transition out.
 

Protected Types

enum class  ScreenTransition { None , In , Out }
 Defines the state of the transition between screens. More...
 

Protected Member Functions

virtual bool ShouldHandleInputBelow ()
 Checks if the screen manager should call HandleInput on the screen below this one.
 
virtual bool ShouldUpdateBelow ()
 Checks if the screen manager should call Update on the screen below this one.
 
virtual bool ShouldDrawBelow ()
 Checks if the screen manager should call Draw on the screen below this one.
 
virtual void SetTransitionInTime (double seconds)
 Set the time in seconds that the screen should transition in.
 
virtual void SetTransitionOutTime (double seconds)
 Set the time in seconds that the screen should transition out.
 
virtual double GetTransitionInTime () const
 Get the time in seconds that the screen will transition in.
 
virtual ScreenTransition GetTransition () const
 Get the current transition state of the screen.
 
virtual float GetTransitionValue () const
 Get the interpolated value (between zero and one) of the screen transition.
 
virtual bool NeedsToBeRemoved () const
 Determines if the screen has completely faded out and needs to be removed by the ScreenManager.
 
virtual void UseRenderTarget ()
 Forces all screen rendering to a render target.
 
virtual RenderTargetGetRenderTarget () const
 Get screen's render target.
 
virtual Color GetRenderTargetColor () const
 Get the color that will be used to tint the render target.
 

Friends

class ScreenManager
 

Detailed Description

Base class for all game screens and menus.

Definition at line 39 of file Screen.h.

Member Enumeration Documentation

◆ ScreenTransition

enum class KatanaEngine::Screen::ScreenTransition
strongprotected

Defines the state of the transition between screens.

Enumerator
None 

The screen is not transitioning.

In 

The screen is transitioning in.

Out 

The screen is transitioning out.

Definition at line 120 of file Screen.h.

Constructor & Destructor Documentation

◆ Screen()

KatanaEngine::Screen::Screen ( )

Definition at line 19 of file Screen.cpp.

◆ ~Screen()

virtual KatanaEngine::Screen::~Screen ( )
inlinevirtual

Definition at line 46 of file Screen.h.

Member Function Documentation

◆ Draw()

virtual void KatanaEngine::Screen::Draw ( SpriteBatch & spriteBatch)
pure virtual

Called when the game determines it is time to draw a frame.

Parameters
spriteBatchA reference to the game's sprite batch, used for rendering.

Implemented in GameplayScreen, KatanaEngine::MenuScreen, and MainMenuScreen.

◆ Exit()

void KatanaEngine::Screen::Exit ( )
virtual

Tells the screen to transition out. When the screen has completed its transition, UnloadContent() will be called, and the ScreenManager will remove it.

Remarks
SetExitCallback() and SetRemoveCallback() can be used to trigger events involving the exiting process.

Definition at line 95 of file Screen.cpp.

◆ GetAlpha()

float KatanaEngine::Screen::GetAlpha ( ) const
inline

Gets the overall screen transition alpha value (or opacity). This is handy for fading screens in and out.

Returns
Returns the alpha value.
Remarks
This function is an alias for the protected GetTransitionValue().
See also
GetTransitionValue()

Definition at line 79 of file Screen.h.

◆ GetGame()

Game * KatanaEngine::Screen::GetGame ( ) const
virtual

Gets a pointer to the Game.

Returns
A pointer to the game instance.

Definition at line 122 of file Screen.cpp.

◆ GetRenderTarget()

virtual RenderTarget * KatanaEngine::Screen::GetRenderTarget ( ) const
inlineprotectedvirtual

Get screen's render target.

Returns
Returns a pointer to the render target, or nullptr if the screen doesn't use one.

Definition at line 175 of file Screen.h.

◆ GetRenderTargetColor()

virtual Color KatanaEngine::Screen::GetRenderTargetColor ( ) const
inlineprotectedvirtual

Get the color that will be used to tint the render target.

Returns
Returns the render target draw tint.

Definition at line 179 of file Screen.h.

◆ GetScreenManager()

virtual ScreenManager * KatanaEngine::Screen::GetScreenManager ( )
inlinevirtual

Gets a pointer to the ScreenManager, for managing game screens.

Returns
A pointer to the game's ScreenManager instance.

Definition at line 83 of file Screen.h.

◆ GetTransition()

virtual ScreenTransition KatanaEngine::Screen::GetTransition ( ) const
inlineprotectedvirtual

Get the current transition state of the screen.

Returns
Returns the current transition.

Definition at line 157 of file Screen.h.

◆ GetTransitionInTime()

virtual double KatanaEngine::Screen::GetTransitionInTime ( ) const
inlineprotectedvirtual

Get the time in seconds that the screen will transition in.

Returns
Returns the transition time in seconds.

Definition at line 153 of file Screen.h.

◆ GetTransitionOutTime()

virtual double KatanaEngine::Screen::GetTransitionOutTime ( ) const
inlinevirtual

Get the time in seconds that the screen will transition out.

Returns
Returns the transition time in seconds.

Definition at line 114 of file Screen.h.

◆ GetTransitionValue()

virtual float KatanaEngine::Screen::GetTransitionValue ( ) const
inlineprotectedvirtual

Get the interpolated value (between zero and one) of the screen transition.

Returns
Returns a value that represents the percentage of the transition. Zero means the screen is entirely transitioned of, and one means it's entirely on.

Definition at line 162 of file Screen.h.

◆ HandleInput()

virtual void KatanaEngine::Screen::HandleInput ( const InputState & input)
inlinevirtual

Called when the game has determined that player input needs to be processed.

Parameters
inputThe current state of all player input devices.

Reimplemented in GameplayScreen, and KatanaEngine::MenuScreen.

Definition at line 60 of file Screen.h.

◆ IsExiting()

virtual bool KatanaEngine::Screen::IsExiting ( ) const
inlinevirtual

Determines if the screen is currently exiting.

Returns
Returns true if the screen is exiting, false otherwise.

Definition at line 72 of file Screen.h.

◆ LoadContent()

virtual void KatanaEngine::Screen::LoadContent ( ResourceManager & resourceManager)
inlinevirtual

Called when resources need to be loaded.

Parameters
resourceManagerA reference to the game's resource manager, used for loading and managing game assets (resources).

Reimplemented in GameplayScreen, and MainMenuScreen.

Definition at line 52 of file Screen.h.

◆ NeedsToBeRemoved()

virtual bool KatanaEngine::Screen::NeedsToBeRemoved ( ) const
inlineprotectedvirtual

Determines if the screen has completely faded out and needs to be removed by the ScreenManager.

Returns
Returns true if the screen needs to be removed, false otherwise.

Definition at line 167 of file Screen.h.

◆ SetExitCallback()

virtual void KatanaEngine::Screen::SetExitCallback ( OnExit callback)
inlinevirtual

Sets the callback function for when the Exit() is called.

Parameters
callbackThe callback function.

Definition at line 105 of file Screen.h.

◆ SetRemoveCallback()

virtual void KatanaEngine::Screen::SetRemoveCallback ( OnRemove callback)
inlinevirtual

Sets the callback function for when the screen is about to be removed by the screen manager.

Parameters
callbackThe callback function.

Definition at line 110 of file Screen.h.

◆ SetScreenManager()

void KatanaEngine::Screen::SetScreenManager ( ScreenManager & screenManager)
virtual

Gets a pointer to the ScreenManager, for managing game screens.

Returns
A pointer to the game's ScreenManager instance.

Definition at line 85 of file Screen.cpp.

◆ SetTransitionInTime()

virtual void KatanaEngine::Screen::SetTransitionInTime ( double seconds)
inlineprotectedvirtual

Set the time in seconds that the screen should transition in.

Parameters
secondsThe transition time.

Definition at line 145 of file Screen.h.

◆ SetTransitionOutTime()

virtual void KatanaEngine::Screen::SetTransitionOutTime ( double seconds)
inlineprotectedvirtual

Set the time in seconds that the screen should transition out.

Parameters
secondsThe transition time.

Definition at line 149 of file Screen.h.

◆ ShouldDrawBelow()

virtual bool KatanaEngine::Screen::ShouldDrawBelow ( )
inlineprotectedvirtual

Checks if the screen manager should call Draw on the screen below this one.

Returns
Returns true if Draw should be called, false otherwise.

Definition at line 141 of file Screen.h.

◆ ShouldHandleInputBelow()

virtual bool KatanaEngine::Screen::ShouldHandleInputBelow ( )
inlineprotectedvirtual

Checks if the screen manager should call HandleInput on the screen below this one.

Returns
Returns true if HandleInput should be called, false otherwise.

Definition at line 130 of file Screen.h.

◆ ShouldUpdateBelow()

virtual bool KatanaEngine::Screen::ShouldUpdateBelow ( )
inlineprotectedvirtual

Checks if the screen manager should call Update on the screen below this one.

Returns
Returns true if Update should be called, false otherwise.
See also
Update()

Definition at line 136 of file Screen.h.

◆ Show()

void KatanaEngine::Screen::Show ( )
virtual

Tells the screen to transition in.

Definition at line 90 of file Screen.cpp.

◆ UnloadContent()

virtual void KatanaEngine::Screen::UnloadContent ( )
inlinevirtual

Called when resources need to be unloaded. Override this method to unload any screen-specific resources.

Definition at line 56 of file Screen.h.

◆ Update()

virtual void KatanaEngine::Screen::Update ( const GameTime & gameTime)
pure virtual

Called when the game has determined that screen logic needs to be processed.

Parameters
gameTimeA reference to the game time object.

Implemented in GameplayScreen, KatanaEngine::MenuScreen, and MainMenuScreen.

◆ UseRenderTarget()

void KatanaEngine::Screen::UseRenderTarget ( )
protectedvirtual

Forces all screen rendering to a render target.

Definition at line 127 of file Screen.cpp.

Friends And Related Symbol Documentation

◆ ScreenManager

friend class ScreenManager
friend

Definition at line 41 of file Screen.h.


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