29 void ScreenManager::HandleInput(
const InputState& input)
31 if (m_screens.size() > 0)
35 for (m_rit = m_screens.rbegin(); m_rit != m_screens.rend(); ++m_rit)
54 if (m_screensToAdd.size() > 0)
56 m_screens.insert(m_screens.end(), m_screensToAdd.begin(), m_screensToAdd.end());
57 m_screensToAdd.clear();
60 if (m_screens.size() > 0)
64 for (m_rit = m_screens.rbegin(); m_rit != m_screens.rend(); ++m_rit)
68 pScreen->UpdateTransition(gameTime);
72 m_screensToRemove.push_back(pScreen);
82 if (m_screensToRemove.size() > 0)
84 for (m_it = m_screensToRemove.begin(); m_it != m_screensToRemove.end(); ++m_it)
88 if (pScreen->m_onRemove) ((
OnRemove)pScreen->m_onRemove)(pScreen);
92 m_screens.erase(std::remove(m_screens.begin(), m_screens.end(), pScreen), m_screens.end());
97 m_screensToRemove.clear();
104 if (m_screens.size() > 0)
106 for (m_rit = m_screens.rbegin(); m_rit != m_screens.rend(); ++m_rit)
110 m_screensToDraw.push_back(pScreen);
115 if (m_screensToDraw.size() > 0)
117 for (m_rit = m_screensToDraw.rbegin(); m_rit != m_screensToDraw.rend(); ++m_rit)
124 (*m_rit)->Draw(spriteBatch);
135 m_screensToDraw.clear();
144 m_screensToAdd.push_back(pScreen);
Base class for all games. Provides graphics initialization, game loop, and rendering code....
virtual ResourceManager * GetResourceManager() const
Gets a pointer to the ResourceManager, for loading and managing resources.
Contains timing values for game updates and rendering.
Contains a 2D texture that can be used as a render target.
static void Set(RenderTarget *pTarget)
Set the desired target to render to when drawing.
Loads and manages the lifespan of objects from external files.
Base class for all game screens and menus.
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 LoadContent(ResourceManager &resourceManager)
Called when resources need to be loaded.
virtual void Update(const GameTime &gameTime)=0
Called when the game has determined that screen logic needs to be processed.
virtual bool NeedsToBeRemoved() const
Determines if the screen has completely faded out and needs to be removed by the ScreenManager.
virtual void UnloadContent()
Called when resources need to be unloaded. Override this method to unload any screen-specific resourc...
virtual Color GetRenderTargetColor() const
Get the color that will be used to tint the render target.
virtual RenderTarget * GetRenderTarget() const
Get screen's render target.
virtual void HandleInput(const InputState &input)
Called when the game has determined that player input needs to be processed.
virtual void SetScreenManager(ScreenManager &screenManager)
Gets a pointer to the ScreenManager, for managing game screens.
virtual bool ShouldHandleInputBelow()
Checks if the screen manager should call HandleInput on the screen below this one.
Game * GetGame() const
Gets a pointer to the Game.
ResourceManager * GetResourceManager() const
Gets a pointer to the ResourceManager, for loading and managing resources.
virtual void AddScreen(Screen *pScreen)
Add a screen to be managed.
virtual void Update(const GameTime &gameTime)
Called when the game has determined that screen logic needs to be processed.
virtual void Draw(SpriteBatch &spriteBatch)
Called when the game determines it is time to draw a frame.
ScreenManager(Game *pGame)
Instantiate a screen manager object.
Enables a group of sprites to be drawn using the same settings.
void Begin(const SpriteSortMode sortMode=SpriteSortMode::Deferred, const BlendState blendState=BlendState::Alpha, ALLEGRO_TRANSFORM *pTransformation=NULL)
Begins a sprite batch operation.
void End()
Flushes the sprite batch and restores the device state to how it was before Begin was called.
void Draw(const Texture *pTexture, const Vector2 position, const Region region, const Color color=Color::White, const Vector2 origin=Vector2::ZERO, const Vector2 scale=Vector2::ONE, const float rotation=0, const float drawDepth=0)
Adds a sprite to a batch of sprites to be rendered.
static const Vector2 ZERO
A vector with both of its components set to zero.
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
void(* OnRemove)(Screen *pScreen)
Callback function for when a screen has completely exited and is about to be removed by the screen ma...