Coverage Summary for Class: PirateGame (com.mygdx.game)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| PirateGame | 0% (0/1) | 0% (0/4) | 0% (0/36) |
1 package com.mygdx.game; 2 3 import com.badlogic.gdx.Application; 4 import com.badlogic.gdx.Game; 5 import com.badlogic.gdx.Gdx; 6 import com.badlogic.gdx.scenes.scene2d.Stage; 7 import com.badlogic.gdx.scenes.scene2d.ui.Skin; 8 import com.badlogic.gdx.utils.viewport.ScreenViewport; 9 import com.mygdx.game.Managers.ResourceManager; 10 import com.mygdx.game.UI.*; 11 12 /** 13 * Contains class instances of game UI screens. 14 */ 15 public class PirateGame extends Game { 16 public MenuScreen menu; 17 public GameScreen game; 18 public EndScreen end; 19 public Stage stage; 20 public Skin skin; 21 public ShopScreen shop; 22 public PowerupScreen powerup; 23 public QuitConfirmationScreen quitConfirm; 24 25 /** 26 * Create instances of game stage and UI screens. 27 */ 28 @Override 29 public void create() { 30 // load resources 31 int id_ship = ResourceManager.addTexture("ship.png"); 32 int id_map = ResourceManager.addTileMap("Map.tmx"); 33 int atlas_id = ResourceManager.addTextureAtlas("Boats.txt"); 34 int extras_id = ResourceManager.addTextureAtlas("UISkin/skin.atlas"); 35 int buildings_id = ResourceManager.addTextureAtlas("Buildings.txt"); 36 ResourceManager.addTexture("menuBG.jpg"); 37 ResourceManager.addTexture("newmenuBG.jpg"); 38 ResourceManager.addTexture("shopBG.jpg"); 39 ResourceManager.addTexture("Chest.png"); 40 ResourceManager.addTexture("powerups/powerup1.png"); 41 ResourceManager.addTexture("powerups/powerup2.png"); 42 ResourceManager.addTexture("powerups/powerup3.png"); 43 ResourceManager.addTexture("powerups/powerup4.png"); 44 ResourceManager.addTexture("powerups/powerup5.png"); 45 ResourceManager.addTexture("powerups/powerup6.png"); 46 ResourceManager.addTexture("points.png"); 47 ResourceManager.loadAssets(); 48 // cant load any more resources after this point (just functionally I choose not to implement) 49 if(!(Application.ApplicationType.HeadlessDesktop == Gdx.app.getType())){ 50 stage = new Stage(new ScreenViewport()); 51 } 52 53 createSkin(); 54 menu = new MenuScreen(this); 55 shop = new ShopScreen(this); 56 game = new GameScreen(this, id_map); 57 end = new EndScreen(this); 58 powerup = new PowerupScreen(this); 59 quitConfirm = new QuitConfirmationScreen(this); 60 setScreen(menu); 61 } 62 63 /** 64 * Clean up prevent memory leeks 65 */ 66 @Override 67 public void dispose() { 68 menu.dispose(); 69 shop.dispose(); 70 game.dispose(); 71 stage.dispose(); 72 skin.dispose(); 73 powerup.dispose(); 74 quitConfirm.dispose(); 75 } 76 77 /** 78 * load ui skin from assets 79 */ 80 private void createSkin() { 81 skin = new Skin(Gdx.files.internal("UISkin/skin.json")); 82 } 83 }