Class GameView

    • Constructor Summary

      Constructors 
      Constructor Description
      GameView​()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCamera​(Camera camera)
      Add a camera to the game.
      static void classInit​()
      Shoud be called before the object get initialized.
      void dispose​()
      should be called if removed from memory
      void drawString​(java.lang.String msg, int xPos, int yPos, com.badlogic.gdx.graphics.Color color)
      Draw a string in a color.
      void drawString​(java.lang.String msg, int xPos, int yPos, com.badlogic.gdx.graphics.Color color, boolean openbatch)
      Draw a string in a color.
      void enter​()
      Should be called when the manager becomes active.
      void exit​()
      Should get called when you leave the editor.
      java.util.ArrayList<Camera> getCameras​()
      Returns a camera.
      Controller getController​()  
      float getEqualizationScale​()
      The equalizationScale is a factor which scales the GUI/HUD to have the same relative size with different resolutions.
      SpriteBatchWithZAxis getGameSpaceSpriteBatch​()
      Game view dependent spriteBatch
      LoadMenu getLoadMenu​()
      Get a menu which can be used for loading maps.
      com.badlogic.gdx.graphics.g2d.SpriteBatch getProjectionSpaceSpriteBatch​()
      Get the value of projectionSpaceSpriteBatch
      RenderStorage getRenderStorage​()  
      com.badlogic.gdx.graphics.glutils.ShaderProgram getShader​()
      Get the loaded shader program of the view.
      com.badlogic.gdx.graphics.glutils.ShapeRenderer getShapeRenderer​()
      to render in screen space with view space scaling?
      com.badlogic.gdx.scenes.scene2d.Stage getStage​()
      The libGDX scene2d stage
      void init​(Controller controller, GameView oldView)
      Loades some files and set up everything when the engine is running.
      boolean isInitalized​()  
      boolean isUsingDefaultShader​()  
      void loadShaders​()
      reloads the shaders
      void onEnter​()
      Override to specify what should happen when the mangager becomes active.
      void preUpdate​(float dt)
      update before the game logic calls
      void render​()
      Main method which is called every time and renders everything.
      void resetProjectionMatrix​()
      sets matrix to render in screen space coordinates
      void resize​(int width, int height)
      should be called when the window get resized
      Intersection screenToGame​(int x, int y)
      Returns the approximated game position belonging to a point on the screen.
      Point screenToGameBasic​(int x, int y)
      Returns matching point on the ground.
      float screenXtoView​(int screenX, Camera camera)
      Reverts the perspective and transforms it into a coordiante which can be used in the game logic.
      float screenYtoView​(int screenY, Camera camera)
      Reverts the projection and transforms it into game space.
      void setRenderStorage​(RenderStorage renderstorage)  
      void setShader​(com.badlogic.gdx.graphics.glutils.ShaderProgram shader)  
      void update​(float dt)
      Updates every camera and everything else which must be updated.
      void useDefaultShader​()  
      int viewToScreenX​(int x, Camera camera)
      Not a homomorphism, which means f(a*b) !
      int viewToScreenY​(int y, Camera camera)
      Not a homomorphism, which means f(a*b) !
      • Methods inherited from class java.lang.Object

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

      • GameView

        public GameView​()
    • Method Detail

      • classInit

        public static void classInit​()
        Shoud be called before the object get initialized. Initializes class fields.
      • init

        public void init​(Controller controller,
                         GameView oldView)
        Loades some files and set up everything when the engine is running. After this has been inactive use onEnter()
        This method is a an implementation of the Setter Injection pattern.
        Parameters:
        controller - The dependent data controller used for the view. Can be null but should not.
        oldView - The view used before. Can be null.
        See Also:
        onEnter()
      • getShader

        public com.badlogic.gdx.graphics.glutils.ShaderProgram getShader​()
        Get the loaded shader program of the view.
        Returns:
      • loadShaders

        public void loadShaders​()
        reloads the shaders
      • onEnter

        public void onEnter​()
        Description copied from interface: GameManager
        Override to specify what should happen when the mangager becomes active. Super call must not be implemented.
        Specified by:
        onEnter in interface GameManager
      • preUpdate

        public void preUpdate​(float dt)
        update before the game logic calls
        Parameters:
        dt -
      • update

        public void update​(float dt)
        Updates every camera and everything else which must be updated.
        Parameters:
        dt - time since last update in ms.
      • getRenderStorage

        public RenderStorage getRenderStorage​()
        Returns:
      • setRenderStorage

        public void setRenderStorage​(RenderStorage renderstorage)
        Parameters:
        renderstorage -
      • render

        public void render​()
        Main method which is called every time and renders everything. You must manually render the devtools e.g. in an extended render method.
      • resetProjectionMatrix

        public void resetProjectionMatrix​()
        sets matrix to render in screen space coordinates
      • getEqualizationScale

        public float getEqualizationScale​()
        The equalizationScale is a factor which scales the GUI/HUD to have the same relative size with different resolutions.
        Returns:
        the scale factor
      • screenXtoView

        public float screenXtoView​(int screenX,
                                   Camera camera)
        Reverts the perspective and transforms it into a coordiante which can be used in the game logic. Should be verified if returning correct results.
        Parameters:
        screenX - the x position on the screen
        camera - the camera where the position is on
        Returns:
        view coordinate
      • screenYtoView

        public float screenYtoView​(int screenY,
                                   Camera camera)
        Reverts the projection and transforms it into game space. Should be verified if returning correct results.
        Parameters:
        screenY - the y position on the screen. y-up
        camera - the camera where the position is on
        Returns:
        view coordinate
      • screenToGameBasic

        public Point screenToGameBasic​(int x,
                                       int y)
        Returns matching point on the ground. Can be used in game space but then its on the floor layer.
        Parameters:
        x - screen space
        y - screen space. y-up
        Returns:
        the position on the map. deepest layer. If no camera returns map center.
      • screenToGame

        public Intersection screenToGame​(int x,
                                         int y)
        Returns the approximated game position belonging to a point on the screen. Does raytracing to find the intersection. Because information is lost if you do game to screen reverting this can only be done by approximating what happens in view -> game. First does screen -> view and then via raytracing view -> game.
        Parameters:
        x - the x position on the screen from left
        y - the y position on the screen from bottom
        Returns:
        the position on the map. can return null if no camera available
      • viewToScreenX

        public int viewToScreenX​(int x,
                                 Camera camera)
        Not a homomorphism, which means f(a*b) != f(a)*f(b)
        Parameters:
        x - view space
        camera -
        Returns:
        screen space
      • viewToScreenY

        public int viewToScreenY​(int y,
                                 Camera camera)
        Not a homomorphism, which means f(a*b) != f(a)*f(b)
        Parameters:
        y - view space
        camera -
        Returns:
        screen space
      • drawString

        public void drawString​(java.lang.String msg,
                               int xPos,
                               int yPos,
                               com.badlogic.gdx.graphics.Color color,
                               boolean openbatch)
        Draw a string in a color.
        Parameters:
        msg -
        xPos - screen space
        yPos - screen space
        color -
        openbatch - true if begin/end shoould be called
      • drawString

        public void drawString​(java.lang.String msg,
                               int xPos,
                               int yPos,
                               com.badlogic.gdx.graphics.Color color)
        Draw a string in a color. Using open batch.
        Parameters:
        msg -
        xPos - screen space
        yPos - screen space
        color -
      • getShapeRenderer

        public com.badlogic.gdx.graphics.glutils.ShapeRenderer getShapeRenderer​()
        to render in screen space with view space scaling?
        Returns:
      • getController

        public Controller getController​()
        Returns:
      • getCameras

        public java.util.ArrayList<Camera> getCameras​()
        Returns a camera. The first camera is handled as the main camera.
        Returns:
        The virtual cameras rendering the scene
      • getLoadMenu

        public LoadMenu getLoadMenu​()
        Get a menu which can be used for loading maps.
        Returns:
      • addCamera

        public void addCamera​(Camera camera)
        Add a camera to the game. Adds this camera to the used RenderStorage.
        Parameters:
        camera -
      • resize

        public void resize​(int width,
                           int height)
        should be called when the window get resized
        Parameters:
        width -
        height -
      • getStage

        public com.badlogic.gdx.scenes.scene2d.Stage getStage​()
        The libGDX scene2d stage
        Returns:
      • getGameSpaceSpriteBatch

        public SpriteBatchWithZAxis getGameSpaceSpriteBatch​()
        Game view dependent spriteBatch
        Returns:
      • getProjectionSpaceSpriteBatch

        public com.badlogic.gdx.graphics.g2d.SpriteBatch getProjectionSpaceSpriteBatch​()
        Get the value of projectionSpaceSpriteBatch
        Returns:
        the value of projectionSpaceSpriteBatch
      • useDefaultShader

        public void useDefaultShader​()
      • isUsingDefaultShader

        public boolean isUsingDefaultShader​()
        Returns:
      • setShader

        public void setShader​(com.badlogic.gdx.graphics.glutils.ShaderProgram shader)
        Parameters:
        shader -
      • exit

        public void exit​()
        Description copied from interface: GameManager
        Should get called when you leave the editor. To extend this method you should overwrite adn call super ethod.
        Specified by:
        exit in interface GameManager
      • dispose

        public void dispose​()
        Description copied from interface: GameManager
        should be called if removed from memory
        Specified by:
        dispose in interface GameManager