/** @param path */
  public LoadTexture(String path) {
    array_Texs.add(new Texture(path));
    array_Texs.get(BACKGROUND).setFilter(TextureFilter.Linear, TextureFilter.Linear);
    array_Texs.add(new Texture(Gdx.files.internal("data/arrow-down.png")));
    array_Texs.add(new Texture(Gdx.files.internal("data/arrow-up.png")));
    array_Texs.add(new Texture(Gdx.files.internal("data/menu.png")));

    for (int i = 0; i < array_Texs.size(); i++) {
      array_TexRegions.add(
          new TextureRegion(
              array_Texs.get(i),
              0,
              0,
              array_Texs.get(i).getWidth(),
              array_Texs.get(i).getHeight()));
      array_Sprites.add(new Sprite(array_TexRegions.get(i)));
    }

    // 背景画像設定
    Sprite sprite = array_Sprites.get(BACKGROUND);
    sprite.setSize(sprite.getRegionWidth(), sprite.getRegionHeight());
    sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
    sprite.setPosition(-sprite.getWidth() / 2, -sprite.getHeight() / 2);
    array_Sprites.set(BACKGROUND, sprite);
  }
示例#2
0
  /**
   * Draws the objects
   *
   * @param batch
   * @param imageHandler
   */
  public void draw(SpriteBatch batch, ImageHandler imageHandler) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_INTRO)) {
      player1.drawWithOffset(batch, 0, -intro_player_offset);

      for (Enemy badGuy : enemies) {
        badGuy.drawWithOffset(batch, 0, intro_enemy_offset);
      }
    } else {
      player1.draw(batch);

      for (Enemy badGuy : enemies) {
        badGuy.draw(batch);
      }

      for (Projectile proj : projectiles) {
        proj.draw(batch);
      }

      for (Explosion exp : explosions) {
        exp.draw(batch);
      }
    }

    scoreText.draw(batch, Integer.toString(score), 10, 750, 4);

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_PAUSED)) {
      pauseMenu.draw(batch);
    }

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_GAME_OVER)) {
      gameOverMenu.draw(batch);
    }

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_INTRO_START)) {
      int draw_x = 450;
      int draw_y = 200;
      int size = 8;
      for (Sprite img : startText) {
        img.setPosition(draw_x, draw_y);
        img.setSize((int) (img.getRegionWidth() * size), (int) (img.getRegionHeight() * size));
        img.draw(batch);
        draw_x += img.getRegionWidth() * size;
      }
    }
  }