Example #1
0
  @Override
  public void asserts() {
    assertTrue(dstFile.exists());
    assertEquals(dstFile.length(), image.length());
    dstFile.delete();

    assertTrue(dstFile2.exists());
    assertEquals(dstFile2.length(), image.length());
    dstFile2.delete();
  }
Example #2
0
  /**
   * If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix
   * params.texturePrefix}, an {@link AssetDescriptor} for the file referenced on that line will be
   * added to the returned Array. Otherwise a sibling of the given file with the same name and the
   * first found extension in {@link PolygonRegionParameters#textureExtensions
   * params.textureExtensions} will be used. If no suitable file is found, the returned Array will
   * be empty.
   */
  @Override
  public Array<AssetDescriptor> getDependencies(
      String fileName, FileHandle file, PolygonRegionParameters params) {
    if (params == null) params = defaultParameters;
    String image = null;
    try {
      BufferedReader reader = file.reader(params.readerBuffer);
      for (String line = reader.readLine(); line != null; line = reader.readLine())
        if (line.startsWith(params.texturePrefix)) {
          image = line.substring(params.texturePrefix.length());
          break;
        }
      reader.close();
    } catch (IOException e) {
      throw new GdxRuntimeException("Error reading " + fileName, e);
    }

    if (image == null && params.textureExtensions != null)
      for (String extension : params.textureExtensions) {
        FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension));
        if (sibling.exists()) image = sibling.name();
      }

    if (image != null) {
      Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1);
      deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class));
      return deps;
    }

    return null;
  }
  private Table makeGameFileRow(final FileHandle gameSaveFile) {
    GameSave towerData;
    try {
      towerData = GameSaveFactory.readMetadata(gameSaveFile.read());
    } catch (Exception e) {
      Gdx.app.log(TAG, "Failed to parse file.", e);
      return null;
    }

    FileHandle imageFile =
        Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY + gameSaveFile.name() + ".png");

    Actor imageActor = null;
    if (imageFile.exists()) {
      try {
        imageActor = new Image(loadTowerImage(imageFile), Scaling.fit, Align.top);
      } catch (Exception ignored) {
        imageActor = null;
      }
    }

    if (imageActor == null) {
      imageActor = FontManager.Default.makeLabel("No image.");
    }

    Table fileRow = new Table();
    fileRow.defaults().fillX().pad(Display.devicePixel(10)).space(Display.devicePixel(10));
    fileRow.row();
    fileRow.add(imageActor).width(Display.devicePixel(64)).height(Display.devicePixel(64)).center();
    fileRow.add(makeGameFileInfoBox(fileRow, gameSaveFile, towerData)).expandX().top();
    fileRow.row().fillX();
    fileRow.add(new HorizontalRule(Color.DARK_GRAY, 2)).colspan(2);

    return fileRow;
  }
Example #4
0
 public static Levels loadFromDefault() {
   FileHandle file = Gdx.files.local(PATH);
   if (!file.exists()) {
     Gdx.app.log("INFO", "local file missing; using internal.");
     file = Gdx.files.internal(PATH);
   }
   return loadFromFile(file);
 }
 public TextureManager() {
   FileHandle atlasFile = FileManager.getInstance().getImagesDirectory().child("sol.atlas");
   myTexProvider =
       atlasFile.exists() ? new AtlasTextureProvider(atlasFile) : new DevTextureProvider();
   myPacks = new HashMap<String, ArrayList<TextureAtlas.AtlasRegion>>();
   myTexs = new HashMap<String, TextureAtlas.AtlasRegion>();
   myFlipped = new HashMap<TextureAtlas.AtlasRegion, TextureAtlas.AtlasRegion>();
 }
  private boolean prepareMediaRecorder(String path) {

    this.camera.unlock();
    try {
      this.recorder.setCamera(this.camera);
    } catch (Exception ex) {
      Gdx.app.error(VIDEO_LOGTAG, "Setting camera failed!", ex);
      return false;
    }
    this.recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    this.recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    this.recorder.setProfile(this.mRecorderProfile);

    final FileHandle rootPathHandle = Gdx.files.absolute(path);
    if (!rootPathHandle.exists()) {
      rootPathHandle.mkdirs();
    }
    final int id = 1 + rootPathHandle.list().length;
    this.auxVideoPath = path + File.separator + id + File.separator;
    final FileHandle videoPathHandle = Gdx.files.absolute(this.auxVideoPath);
    if (!videoPathHandle.exists()) {
      videoPathHandle.mkdirs();
    }
    this.recorder.setOutputFile(this.auxVideoPath + VIDEO_ID);
    this.recorder.setMaxDuration(MAX_RECORDING_DURATION);

    this.recorder.setPreviewDisplay(this.holder.getSurface());

    try {
      this.recorder.prepare();
    } catch (IllegalStateException ille) {
      Gdx.app.error(VIDEO_LOGTAG, "Illegal State Exception preparing recorder!", ille);
      releaseRecorder();
      return false;
    } catch (IOException ioex) {
      Gdx.app.error(VIDEO_LOGTAG, "IO Exception preparing recorder!", ioex);
      releaseRecorder();
      return false;
    }
    return true;
  }
  @Override
  public void init() {
    settings = new Settings();
    settings.maxWidth = 4096;
    settings.maxHeight = 4096;
    settings.combineSubdirectories = true;
    settings.silent = true;
    settings.useIndexes = false;
    settings.fast = true;

    loadingRegion = Assets.icons.findRegion("refresh-big");
    missingRegion = Assets.icons.findRegion("file-question-big");

    FileHandle out = fileAccess.getModuleFolder(".textureCache");
    cachePath = out.path();
    cacheFile = out.child("cache.atlas");

    gfxPath = fileAccess.getAssetsFolder().child("gfx").path();
    atlasesFolder = fileAccess.getAssetsFolder().child("atlas");

    watcher.addListener(this);

    try {
      if (cacheFile.exists()) cache = new TextureAtlas(cacheFile);
    } catch (Exception e) {
      Log.error("Error while loading texture cache, texture cache will be regenerated");
    }

    try {
      if (atlasesFolder.exists()) {
        FileHandle[] files = atlasesFolder.list();

        for (FileHandle file : files) if (file.extension().equals("atlas")) updateAtlas(file);
      }
    } catch (Exception e) {
      Log.error("Error encountered while loading one of atlases");
      Log.exception(e);
    }

    updateCache();
  }
  public static void Save(SaveData data) {

    saveData = data;

    FileHandle file = Gdx.files.local("saves/savedata.json");

    if (file.exists()) {
      file.delete();
    }

    String savestring = json.prettyPrint(saveData);
    file.writeString(savestring, true);
  }
Example #9
0
  /**
   * Loads the music located at path
   *
   * @param path
   */
  private static void LoadMusic(final String path) {
    AssetManager assetManager = VictusLudusGame.engine.assetManager;

    FileHandle musicFolder = VFile.getFileHandle(path);
    FileHandle[] files = VFile.getFiles(musicFolder);

    for (FileHandle file : files) {
      if (file.exists() && file.extension().toLowerCase().equals("wav")) {
        assetManager.load(file.path(), Music.class);
        System.out.println("queueing " + file.path());
      }
    }
  }
Example #10
0
  /**
   * Attempts to save the contents of the {@link #mesh} to a file located in the {@link
   * GameStructure#IMAGES_FOLDER}.
   *
   * @return true if everything went OK.
   */
  public boolean save() {
    if (!this.mesh.hasSomethingToSave()) return false;

    // Get a correct image name
    String savingPath = GameStructure.IMAGES_FOLDER;
    I18N i18n = this.controller.getApplicationAssets().getI18N();
    EditorGameAssets gameAssets = this.controller.getEditorGameAssets();
    FileHandle savingDir = gameAssets.resolve(savingPath);
    if (!savingDir.exists()) {
      savingDir.mkdirs();
    }
    String name = i18n.m("element");
    savingPath += name;
    FileHandle savingImage = null;
    int i = 0;
    do {
      savingImage = gameAssets.resolve(savingPath + (++i) + ".png");
    } while (savingImage.exists());

    // Get a correct thumbnail name
    String thumbSavingPath = GameStructure.THUMBNAILS_PATH;
    FileHandle thumbSavingDir = gameAssets.resolve(thumbSavingPath);
    if (!thumbSavingDir.exists()) {
      thumbSavingDir.mkdirs();
    }

    thumbSavingPath += name;
    FileHandle thumbSavingImage = null;
    i = 0;
    do {
      thumbSavingImage = gameAssets.resolve(thumbSavingPath + (++i) + ".png");
    } while (thumbSavingImage.exists());

    this.mesh.save(this.savePath = savingImage, this.thumbSavePath = thumbSavingImage);

    return true;
  }
  private void updateAtlas(FileHandle file) {
    String relativePath = fileAccess.relativizeToAssetsFolder(file);

    TextureAtlas atlas = atlases.get(relativePath);
    if (atlas != null) {
      atlases.remove(relativePath);
      atlas.dispose();
    }

    if (file.exists()) {
      atlases.put(relativePath, new TextureAtlas(file));
      App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURES));
      App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURE_ATLASES));
    }
  }
  public static void ResetSave() {
    saveData =
        new SaveData(
            new PlayerData(PlayerData.AbilityType.NONE, 0, 0, 0, 0, PlayerData.SkinType.HUMAN),
            new LevelSaveData[] {new LevelSaveData(0, 0, true), new LevelSaveData(0, 0, false)},
            0);

    FileHandle file = Gdx.files.local("saves/savedata.json");

    if (file.exists()) {
      file.delete();
    }

    String savestring = json.prettyPrint(saveData);
    file.writeString(savestring, true);
  }
Example #13
0
  /**
   * Loads the 3d meshes located at path
   *
   * @param path
   */
  private static void Load3DMeshes(final String path) {
    AssetManager assetManager = VictusLudusGame.engine.assetManager;

    FileHandle meshFolder = VFile.getFileHandle(path);
    FileHandle[] files = VFile.getFiles(meshFolder);

    for (FileHandle file : files) {
      if (file.exists()
          && (file.extension().toLowerCase().equals("obj")
              || file.extension().toLowerCase().equals("g3db")
              || file.extension().toLowerCase().equals("g3dj"))) {
        assetManager.load(file.path(), Model.class);
        System.out.println("queueing " + file.path());
      }
    }
  }
  public static void Initialize() {

    FileHandle file = Gdx.files.local("saves/savedata.json");
    if (!file.exists()) {

      String savestring =
          json.prettyPrint(
              new SaveData(
                  new PlayerData(
                      PlayerData.AbilityType.NONE, 0, 0, 0, 0, PlayerData.SkinType.HUMAN),
                  new LevelSaveData[] {
                    new LevelSaveData(0, 0, true), new LevelSaveData(0, 0, false)
                  },
                  0));
      file.writeString(savestring, true);
    }
    saveData = json.fromJson(SaveData.class, file);
  }
Example #15
0
  /**
   * Read line items into an array list
   *
   * @param path the path of the file
   * @param array the arraylist to populate
   */
  private static void SimpleReadAndLoad(
      final String path, final ArrayList<String> array, final ISimpleReader reader) {
    FileHandle folder = VFile.getFileHandle(path);

    FileHandle[] listOfFiles = VFile.getFiles(folder);

    for (FileHandle f : listOfFiles) {
      if (f.exists()) {
        reader.ReadAndLoad(f, array);

        if (VictusLudusGame.engine.IS_DEBUGGING) {
          Gdx.app.log("info", "loaded " + f.path());
        }
      } else {
        Gdx.app.log("severe", "<ERROR> Cannot read file [" + f.path() + "]");
        throw new VictusRuntimeException("Could not read resource folder for " + path);
      }
    }
  }
Example #16
0
  public FileHandle getTTFSafely(String fontName) throws IOException {
    FontManager fontManager = facade.retrieveProxy(FontManager.NAME);

    ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
    String expectedPath = projectManager.getFreeTypeFontPath() + File.separator + fontName + ".ttf";
    FileHandle expectedFile = Gdx.files.internal(expectedPath);
    if (!expectedFile.exists()) {
      // let's check if system fonts fot it
      HashMap<String, String> fonts = fontManager.getFontsMap();
      if (fonts.containsKey(fontName)) {
        File source = new File(fonts.get(fontName));
        FileUtils.copyFile(source, expectedFile.file());
        expectedFile = Gdx.files.internal(expectedPath);
      } else {
        throw new FileNotFoundException();
      }
    }

    return expectedFile;
  }
  private void reloadCache() {
    if (cacheFile.exists()) {
      TextureAtlas oldCache = null;

      if (cache != null) oldCache = cache;

      cache = new TextureAtlas(cacheFile);

      for (Entry<String, TextureRegion> e : regions.entries()) {
        String path = FileUtils.removeFirstSeparator(FilenameUtils.removeExtension(e.key));
        TextureRegion region = e.value;
        TextureRegion newRegion = cache.findRegion(path);
        if (newRegion == null) region.setRegion(missingRegion);
        else region.setRegion(newRegion);
      }

      disposeCacheLater(oldCache);

      App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURES));
    } else
      Log.error(
          "Texture cache not ready, probably they aren't any textures in project or packer failed");
  }
  void loadSkeleton(final FileHandle skeletonFile) {
    if (skeletonFile == null) return;

    try {
      // Setup a texture atlas that uses a white image for images not found in the atlas.
      Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
      pixmap.setColor(new Color(1, 1, 1, 0.33f));
      pixmap.fill();
      final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
      pixmap.dispose();

      String atlasFileName = skeletonFile.nameWithoutExtension();
      if (atlasFileName.endsWith(".json"))
        atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension();
      FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas");
      if (!atlasFile.exists()) atlasFile = skeletonFile.sibling(atlasFileName + ".atlas.txt");
      TextureAtlasData data =
          !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
      TextureAtlas atlas =
          new TextureAtlas(data) {
            public AtlasRegion findRegion(String name) {
              AtlasRegion region = super.findRegion(name);
              if (region == null) {
                // Look for separate image file.
                FileHandle file = skeletonFile.sibling(name + ".png");
                if (file.exists()) {
                  Texture texture = new Texture(file);
                  texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
                  region = new AtlasRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
                  region.name = name;
                }
              }
              return region != null ? region : fake;
            }
          };

      // Load skeleton data.
      String extension = skeletonFile.extension();
      if (extension.equalsIgnoreCase("json") || extension.equalsIgnoreCase("txt")) {
        SkeletonJson json = new SkeletonJson(atlas);
        json.setScale(ui.scaleSlider.getValue());
        skeletonData = json.readSkeletonData(skeletonFile);
      } else {
        SkeletonBinary binary = new SkeletonBinary(atlas);
        binary.setScale(ui.scaleSlider.getValue());
        skeletonData = binary.readSkeletonData(skeletonFile);
        if (skeletonData.getBones().size == 0) throw new Exception("No bones in skeleton data.");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      ui.toast("Error loading skeleton: " + skeletonFile.name());
      lastModifiedCheck = 5;
      return;
    }

    skeleton = new Skeleton(skeletonData);
    skeleton.setToSetupPose();
    skeleton = new Skeleton(skeleton); // Tests copy constructors.
    skeleton.updateWorldTransform();

    state = new AnimationState(new AnimationStateData(skeletonData));
    state.addListener(
        new AnimationStateAdapter() {
          public void event(TrackEntry entry, Event event) {
            ui.toast(event.getData().getName());
          }
        });

    this.skeletonFile = skeletonFile;
    prefs.putString("lastFile", skeletonFile.path());
    prefs.flush();
    lastModified = skeletonFile.lastModified();
    lastModifiedCheck = checkModifiedInterval;

    // Populate UI.

    ui.window.getTitleLabel().setText(skeletonFile.name());
    {
      Array<String> items = new Array();
      for (Skin skin : skeletonData.getSkins()) items.add(skin.getName());
      ui.skinList.setItems(items);
    }
    {
      Array<String> items = new Array();
      for (Animation animation : skeletonData.getAnimations()) items.add(animation.getName());
      ui.animationList.setItems(items);
    }
    ui.trackButtons.getButtons().first().setChecked(true);

    // Configure skeleton from UI.

    if (ui.skinList.getSelected() != null) skeleton.setSkin(ui.skinList.getSelected());
    setAnimation();

    // ui.animationList.clearListeners();
    // state.setAnimation(0, "walk", true);
  }
Example #19
0
  public static void load() {
    // TEXTURES has to be in Formtat: 2^x * 2^y
    loadNumbers();
    loadBlocks();
    loadPlayerTextures();

    logoTexture = new Texture(Gdx.files.internal("data/logo.png"));
    logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new TextureRegion(logoTexture, 0, 0, 512, 114);

    texture = new Texture(Gdx.files.internal("data/texture.png"));
    texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

    FileHandle test = Gdx.files.internal("data/touchBackground.png");
    System.out.println(test.exists());
    touchKnob = new Texture(test);
    touchKnob.setFilter(TextureFilter.Linear, TextureFilter.Nearest);

    playButtonUp = new TextureRegion(texture, 0, 83, 29, 16);
    playButtonUp.flip(false, true);

    playButtonDown = new TextureRegion(texture, 29, 83, 29, 16);
    playButtonDown.flip(false, true);

    playerFace = new Texture(Gdx.files.internal("data/playerLogo.png"));
    playerLogo = new TextureRegion(playerFace, 0, 0, playerFace.getWidth(), playerFace.getHeight());
    playerLogo.flip(false, true);

    ready = new TextureRegion(texture, 59, 83, 34, 7);
    ready.flip(false, true);

    retry = new TextureRegion(texture, 59, 110, 33, 7);
    retry.flip(false, true);

    gameOver = new TextureRegion(texture, 59, 92, 46, 7);
    gameOver.flip(false, true);

    scoreboard = new TextureRegion(texture, 111, 83, 97, 37);
    scoreboard.flip(false, true);

    star = new TextureRegion(texture, 152, 70, 10, 10);
    noStar = new TextureRegion(texture, 165, 70, 10, 10);

    star.flip(false, true);
    noStar.flip(false, true);

    highScore = new TextureRegion(texture, 59, 101, 48, 7);
    highScore.flip(false, true);

    zbLogo = new TextureRegion(texture, 0, 55, 135, 24);
    zbLogo.flip(false, true);

    bg = new TextureRegion(texture, 0, 0, 136, 43);
    bg.flip(false, true);

    block = new TextureRegion(texture, 0, 100, 34, 25);
    block.flip(false, true);

    grass = new TextureRegion(texture, 0, 43, 143, 11);
    grass.flip(false, false);

    birdDown = new TextureRegion(texture, 136, 0, 17, 12);
    birdDown.flip(false, true);

    bird = new TextureRegion(texture, 153, 0, 17, 12);
    bird.flip(false, true);

    birdUp = new TextureRegion(texture, 170, 0, 17, 12);
    birdUp.flip(false, true);

    TextureRegion[] birds = {birdDown, bird, birdUp};
    birdAnimation = new Animation(0.06f, birds);
    birdAnimation.setPlayMode(Animation.LOOP_PINGPONG);

    skullUp = new TextureRegion(texture, 192, 0, 24, 14);
    // Create by flipping existing skullUp
    skullDown = new TextureRegion(skullUp);
    skullDown.flip(false, true);

    bar = new TextureRegion(texture, 136, 16, 22, 3);
    bar.flip(false, true);

    //		dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
    //		flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav"));
    //		coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
    //		fall = Gdx.audio.newSound(Gdx.files.internal("data/fall.wav"));

    font = new BitmapFont(Gdx.files.internal("data/text.fnt"));
    font.setScale(.25f, -.25f);

    whiteFont = new BitmapFont(Gdx.files.internal("data/whitetext.fnt"));
    whiteFont.setScale(.1f, -.1f);

    shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt"));
    shadow.setScale(.25f, -.25f);

    // Create (or retrieve existing) preferences file
    prefs = Gdx.app.getPreferences("ZombieBird");

    if (!prefs.contains("highScore")) {
      prefs.putInteger("highScore", 0);
    }
  }
Example #20
0
  public void stopRecording(DeviceVideoControl.RecordingListener listener) {
    if (!this.recording && listener != null) {
      listener.onVideoFinishedRecording(false);
      waitPreviewTime();
      return;
    }
    // Stop recording and release camera
    try {
      this.recorder.stop();
    } catch (Exception ex) {
      Gdx.app.error(VIDEO_LOGTAG, "Stop failed! cleaning file", ex);
      this.recording = false;
      if (listener != null) {
        listener.onVideoFinishedRecording(false);
      }
      FileHandle corruptFile = Gdx.files.absolute(auxVideoPath + VIDEO_ID);
      if (corruptFile.exists()) {
        corruptFile.delete();
      }
      waitPreviewTime();
      return;
    }
    final String thumbPath = this.auxVideoPath;

    final String miniKindPath = thumbPath + VIDEO_THUMBNAIL_ID;

    OutputStream thumbnailFos = null;
    try {
      // MINI_KIND Thumbnail
      Bitmap bmMiniKind =
          ThumbnailUtils.createVideoThumbnail(this.auxVideoPath + VIDEO_ID, Thumbnails.MINI_KIND);

      if (bmMiniKind == null) {
        Gdx.app.error(VIDEO_LOGTAG, "Video corrupt or format not supported! (MINI_KIND)");
        this.recording = false;
        if (listener != null) {
          listener.onVideoFinishedRecording(false);
        }
        waitPreviewTime();
        return;
      }

      thumbnailFos = new FileOutputStream(new File(miniKindPath));
      bmMiniKind.compress(Bitmap.CompressFormat.JPEG, 90, thumbnailFos);
      thumbnailFos.flush();

      if (bmMiniKind != null) {
        bmMiniKind.recycle();
        bmMiniKind = null;
      }

      if (listener != null) {
        listener.onVideoFinishedRecording(true);
      }
      Gdx.app.log(VIDEO_LOGTAG, "Recording stopped, video thumbnail saved!");
    } catch (FileNotFoundException fnfex) {
      if (listener != null) {
        listener.onVideoFinishedRecording(false);
      }
      Gdx.app.error("Picture", "File not found creating the video thumbnail", fnfex);
    } catch (IOException ioex) {
      // Something went wrong creating the video thumbnail
      if (listener != null) {
        listener.onVideoFinishedRecording(false);
      }
      Gdx.app.error(VIDEO_LOGTAG, "Something went wrong creating the Video Thumbnail", ioex);
    } finally {
      close(thumbnailFos);
    }
    waitPreviewTime();
    this.recording = false;
  }
Example #21
0
  public void resize(int width, int height) {
    MiningAdventure.mining.setCurrentScreen(MiningAdventure.START_SCREEN);

    this.width = width;
    this.height = height;

    buttonHeight = height / 9F;

    float spacer = 10F;
    float buttonWidth = (width * ((3F / 4F) / 2F));

    text = MiningAdventure.label;

    levelExp =
        new Button(
            text,
            "External Level",
            (width / 2F) - (buttonWidth),
            height - (buttonHeight + spacer),
            (buttonWidth * 2F),
            buttonHeight);

    level1 =
        new Button(
            text,
            "Level 1",
            (width / 2F) - ((buttonWidth)),
            levelExp.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level2 =
        new Button(
            text,
            "Level 2",
            (width / 2F) - ((buttonWidth)),
            level1.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level3 =
        new Button(
            text,
            "Level 3",
            (width / 2F) - ((buttonWidth)),
            level2.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level4 =
        new Button(
            text,
            "Level 4",
            level1.x + level1.width + spacer,
            levelExp.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level5 =
        new Button(
            text,
            "Level 5",
            level2.x + level2.width + spacer,
            level4.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level6 =
        new Button(
            text,
            "Level 6",
            level3.x + level3.width + spacer,
            level5.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);

    options =
        new Button(
            text,
            "Options",
            (width / 2F) - (buttonWidth),
            (spacer * 2) + buttonHeight,
            (buttonWidth * 2F),
            buttonHeight);
    exit =
        new Button(
            text, "Exit", (width / 2F) - (buttonWidth), spacer, (buttonWidth * 2F), buttonHeight);

    buttons.clear();

    if (Gdx.files.isExternalStorageAvailable()) {
      FileHandle file = new FileHandle(Gdx.files.getExternalStoragePath() + "levelExp.txt");
      System.out.println(file.path());
      if (file.exists()) {
        buttons.add(levelExp.setActionNumber(-1));
      }
    }

    buttons.add(level1.setActionNumber(1));
    buttons.add(level2.setActionNumber(2));
    buttons.add(level3.setActionNumber(3));

    buttons.add(level4.setActionNumber(4));
    /*buttons.add(level5.setActionNumber(5));
    buttons.add(level6.setActionNumber(6));*/

    buttons.add(options.setActionNumber(-3));
    buttons.add(exit.setActionNumber(-2));
  }