Class PlayScreen

  • All Implemented Interfaces:
    com.badlogic.gdx.Screen

    public class PlayScreen
    extends java.lang.Object
    implements com.badlogic.gdx.Screen
    The PlayScreen class represents a screen which is shown after the game starts, implementing Screen interface. It manages the various game cameras, the Character, and the Area vector which the player can explore. All assets for the game are preloaded when PlayScreen is constructed.
    Author:
    ENG1 Team 23 (Cohort 3)
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  PlayScreen.GameState
      Distinguish between internal game states; used to inform, among others, the render(float)} and handleInput() cycles
    • Constructor Summary

      Constructors 
      Constructor Description
      PlayScreen​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Instantiates a new PlayScreen to be used for the playing area of the game.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void advanceDay()
      Advances the day, or finishes the game as appropriate.
      void dispose()
      Releases all resources used by the PlayScreen
      private void handleInput()
      Handles user system events, such as key-presses.
      void hide()
      Handles the PlayScreen being hidden
      private void initialiseAreas()
      Initialise the play Areas
      void pause()
      Handles the PlayScreen, and hence general gameplay execution, being paused
      void render​(float delta)
      Handles the graphical rendering obligations of the Screen.
      void resize​(int width, int height)
      Handles the PlayScreen being resized
      void resume()
      Handles the PlayScreen, and hence general gameplay execution, being resumed
      void show()
      Handles the PlayScreen becoming the active Screen; currently a placeholder
      void switchArea​(Area.Name areaName)
      Switch to the Area identified by the given Area.Name key
      private void togglePaused()
      Toggle the state such that the game is paused or resumed, unless the game is over
      private void update()
      Handles the game logic and updates the state of the game world
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PlayScreen

        PlayScreen​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
            throws InvalidAreaException
        Instantiates a new PlayScreen to be used for the playing area of the game. This constructor loads all assets for all stages of the playing area, to be manipulated and rendered when required.
        Parameters:
        batch - The LibGDX SpriteBatch to use for batch object rendering
        Throws:
        InvalidAreaException - At least one Area required by the PlayScreen could not be properly instantiated by the AreaFactory
    • Method Detail

      • handleInput

        private void handleInput()
        Handles user system events, such as key-presses.
      • update

        private void update()
        Handles the game logic and updates the state of the game world
      • resize

        public void resize​(int width,
                           int height)
        Handles the PlayScreen being resized
        Specified by:
        resize in interface com.badlogic.gdx.Screen
        Parameters:
        width - The new width, in pixels
        height - The new height, in pixels
      • show

        public void show()
        Handles the PlayScreen becoming the active Screen; currently a placeholder
        Specified by:
        show in interface com.badlogic.gdx.Screen
        See Also:
        hide()
      • hide

        public void hide()
        Handles the PlayScreen being hidden
        Specified by:
        hide in interface com.badlogic.gdx.Screen
        See Also:
        show()
      • pause

        public void pause()
        Handles the PlayScreen, and hence general gameplay execution, being paused
        Specified by:
        pause in interface com.badlogic.gdx.Screen
        See Also:
        resume(), pauseMenu
      • resume

        public void resume()
        Handles the PlayScreen, and hence general gameplay execution, being resumed
        Specified by:
        resume in interface com.badlogic.gdx.Screen
        See Also:
        pause()
      • togglePaused

        private void togglePaused()
        Toggle the state such that the game is paused or resumed, unless the game is over
        See Also:
        PlayScreen.GameState
      • dispose

        public void dispose()
        Releases all resources used by the PlayScreen
        Specified by:
        dispose in interface com.badlogic.gdx.Screen
      • render

        public void render​(float delta)
        Handles the graphical rendering obligations of the Screen. In particular, this involves rendering all visible objects including the Area and all Drawable elements therein TiledMap---, the Character, and various Overlay users.
        Specified by:
        render in interface com.badlogic.gdx.Screen
        Parameters:
        delta - The time in seconds since the last render
        See Also:
        Area, Character