Class HustleGame

java.lang.Object
com.badlogic.gdx.Game
com.skloch.game.HustleGame
All Implemented Interfaces:
com.badlogic.gdx.ApplicationListener

public class HustleGame extends com.badlogic.gdx.Game
A class that is initially created by DesktopLauncher, loads consistent files at the start of the game and initialises lots of important classes. Loads the map, ui skin, text files and makes sound manager and more
  • Field Details

    • batch

      public com.badlogic.gdx.graphics.g2d.SpriteBatch batch
    • WIDTH

      public int WIDTH
    • HEIGHT

      public int HEIGHT
    • skin

      public com.badlogic.gdx.scenes.scene2d.ui.Skin skin
    • map

      public com.badlogic.gdx.maps.tiled.TiledMap map
    • credits

      public String credits
    • tutorialText

      public String tutorialText
    • gameScreen

      public GameScreen gameScreen
    • shapeRenderer

      public com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer
    • soundManager

      public SoundManager soundManager
    • blueBackground

      public com.badlogic.gdx.scenes.scene2d.Stage blueBackground
    • backgroundLayers

      public int[] backgroundLayers
    • foregroundLayers

      public int[] foregroundLayers
    • objectLayers

      public int[] objectLayers
    • mapSquareSize

      public int mapSquareSize
    • mapScale

      public float mapScale
    • mapProperties

      public com.badlogic.gdx.maps.MapProperties mapProperties
  • Constructor Details

    • HustleGame

      public HustleGame(int width, int height)
      A class to initialise a lot of the assets required for the game, including the map, sound and UI skin. A instance of this object should be shared to most screens to allow resources to be shared and disposed of correctly. Should be created in DesktopLauncher,
      Parameters:
      width - Width of the window
      height - Height of the window
  • Method Details

    • create

      public void create()
      Loads resources used throughout the game. Creates a new spritebatch Loads the UI skin to use Loads the map and configures which layers are background, foreground and object layers Loads a shape renderer for debug options Loads a sound manager to play sounds Loads credit and tutorial texts Creates a stage with a blue background for screens to use
    • render

      public void render()
      Very important, renders the game, remove super.render() to get a black screen
      Specified by:
      render in interface com.badlogic.gdx.ApplicationListener
      Overrides:
      render in class com.badlogic.gdx.Game
    • dispose

      public void dispose()
      Disposes of elements that are loaded at the start of the game
      Specified by:
      dispose in interface com.badlogic.gdx.ApplicationListener
      Overrides:
      dispose in class com.badlogic.gdx.Game
    • readTextFile

      public String readTextFile(String filepath)
      Reads and returns text read from the provided text file path
      Parameters:
      filepath - The path to the text file
      Returns:
      The contents of the file as a String