Arcade Shooter
Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
KatanaEngine::Screen Class Referenceabstract

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

#include <Screen.h>

Inheritance diagram for KatanaEngine::Screen:
KatanaEngine::MenuScreen Sample::LevelOverScreen Sample::MenuScreen Sample::MainMenuScreen Sample::PauseMenuScreen

Public Member Functions

virtual void LoadContent (ResourceManager *pResourceManager)
 Called when resources need to be loaded. More...
 
virtual void UnloadContent ()
 Called when resources need to be unloaded. Override this method to unload any screen-specific resources.
 
virtual void HandleInput (const InputState *pInput)
 Called when the game has determined that player input needs to be processed. More...
 
virtual void Update (const GameTime *pGameTime)=0
 Called when the game has determined that screen logic needs to be processed. More...
 
virtual void Draw (SpriteBatch *pSpriteBatch)=0
 Called when the game determines it is time to draw a frame. More...
 
virtual bool IsExiting () const
 Determines if the screen is currently exiting. More...
 
float GetAlpha () const
 Gets the overall screen transition alpha value (or opacity). This is handy for fading screens in and out. More...
 
virtual ScreenManagerGetScreenManager ()
 Gets a pointer to the ScreenManager, for managing game screens. More...
 
virtual GameGetGame () const
 Gets a pointer to the Game. More...
 
virtual ParticleManagerGetParticleManager () const
 Gets a pointer to the ParticleManager, for creating and managing particles. More...
 
virtual void SetScreenManager (ScreenManager *pScreenManager)
 Gets a pointer to the ScreenManager, for managing game screens. More...
 
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. More...
 
virtual void SetExitCallback (OnExit callback)
 Sets the callback function for when the Exit() is called. More...
 
virtual void SetRemoveCallback (OnRemove callback)
 Sets the callback function for when the screen is about to be removed by the screen manager. More...
 
virtual double GetTransitionOutTime () const
 Get the time in seconds that the screen will transition out. More...
 

Protected Types

enum  ScreenTransition {
  ScreenTransition::NONE,
  ScreenTransition::IN,
  ScreenTransition::OUT
}
 Defines the state of the transition between screens. More...
 

Protected Member Functions

virtual void SetPassthroughFlags (const bool draw=false, const bool update=false, const bool handleInput=false)
 Sets the flags that determine if the underlaying screen should handle input, update, and/or render. More...
 
virtual void SetTransitionInTime (double seconds)
 Set the time in seconds that the screen should transition in. More...
 
virtual void SetTransitionOutTime (double seconds)
 Set the time in seconds that the screen should transition out. More...
 
virtual double GetTransitionInTime () const
 Get the time in seconds that the screen will transition in. More...
 
virtual ScreenTransition GetTransition () const
 Get the current transition state of the screen. More...
 
virtual float GetTransitionValue () const
 Get the interpolated value (between zero and one) of the screen transition. More...
 
virtual bool NeedsToBeRemoved () const
 Determines if the screen has completely faded out and needs to be removed by the ScreenManager. More...
 
virtual void UseRenderTarget ()
 Forces all screen rendering to a render target.
 
virtual RenderTargetGetRenderTarget () const
 Get screen's render target. More...
 
virtual Color GetRenderTargetColor () const
 Get the color that will be used to tint the render target. More...
 

Friends

class ScreenManager
 

Detailed Description

Base class for all game screens and menus.

Member Enumeration Documentation

◆ ScreenTransition

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.

Member Function Documentation

◆ Draw()

virtual void KatanaEngine::Screen::Draw ( SpriteBatch pSpriteBatch)
pure virtual

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

Parameters
pSpriteBatchThe game's sprite batch, used for rendering.

Implemented in KatanaEngine::MenuScreen.

◆ Exit()

void 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.

◆ 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()

◆ GetGame()

Game * Screen::GetGame ( ) const
virtual

Gets a pointer to the Game.

Returns
A pointer to the game instance.

◆ GetParticleManager()

ParticleManager * Screen::GetParticleManager ( ) const
virtual

Gets a pointer to the ParticleManager, for creating and managing particles.

Returns
A pointer to the game's ParticleManager instance.

◆ 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.

◆ 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.

◆ 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.

◆ GetTransition()

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

Get the current transition state of the screen.

Returns
Returns the current transition.

◆ 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.

◆ 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.

◆ 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.

◆ HandleInput()

virtual void KatanaEngine::Screen::HandleInput ( const InputState pInput)
inlinevirtual

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

Parameters
pInputThe current state of all player input devices.

Reimplemented in KatanaEngine::MenuScreen.

◆ 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.

◆ LoadContent()

virtual void KatanaEngine::Screen::LoadContent ( ResourceManager pResourceManager)
inlinevirtual

Called when resources need to be loaded.

Parameters
pResourceManagerThe game's resource manager, used for loading and managing game resources.

◆ 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.

◆ SetExitCallback()

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

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

Parameters
callbackThe callback function.

◆ SetPassthroughFlags()

void Screen::SetPassthroughFlags ( const bool  draw = false,
const bool  update = false,
const bool  handleInput = false 
)
protectedvirtual

Sets the flags that determine if the underlaying screen should handle input, update, and/or render.

Parameters
drawSet this flag to true if the underlaying screen should render.
updateSet this flag to true if the underlaying screen should update.
handleInputSet this flag to true if the underlaying screen should handle user input.

◆ 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.

◆ SetScreenManager()

void Screen::SetScreenManager ( ScreenManager pScreenManager)
virtual

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

Returns
A pointer to the game's ScreenManager instance.

◆ SetTransitionInTime()

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

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

Parameters
secondsThe transition time.

◆ SetTransitionOutTime()

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

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

Parameters
secondsThe transition time.

◆ Update()

virtual void KatanaEngine::Screen::Update ( const GameTime pGameTime)
pure virtual

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

Parameters
pGameTimeTiming values including time since last update.

Implemented in KatanaEngine::MenuScreen.


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