Exemplo n.º 1
0
  @Override
  protected void onCreateResources() throws IOException {
    this.gameManager = GomokuGameManager.getInstance();
    this.gameManager.setCallback(this);
    this.gameManager.initialize(COLUMNS - 1, ROWS - 1);
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

    this.mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(this.getTextureManager(), 512, 512);
    this.blankRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            mBitmapTextureAtlas, this, "blankIcon.png");
    this.xRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            mBitmapTextureAtlas, this, "xIcon.png");
    this.oRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            mBitmapTextureAtlas, this, "oIcon.png");
    this.winRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            mBitmapTextureAtlas, this, "blueIcon.png");
    try {
      this.mBitmapTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 1));
      this.mBitmapTextureAtlas.load();
    } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }
  private void loadAboutGraphics() {
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/about/");
    aboutTextureAtlas =
        new BuildableBitmapTextureAtlas(
            activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);

    aboutBackgroundTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            aboutTextureAtlas, activity, "background.jpg");

    try {
      aboutTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
      aboutTextureAtlas.load();
    } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }
  private void loadMainMenuGraphics() {

    if (menuTextureAtlas != null) {
      menuTextureAtlas.load();
      return;
    }

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/menu/");
    menuTextureAtlas =
        new BuildableBitmapTextureAtlas(
            activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);

    menuBackgroundTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "background.jpg");
    buttonAboutTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "menu_help.png");
    buttonExitTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "menu_exit.png");
    buttonNewGameTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "menu_new.png");
    buttonOptionsTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "menu_options.png");
    buttonHighScoreTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "menu_high.png");
    buttonMultiplayerTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            menuTextureAtlas, activity, "menu_multiplayer.png");

    try {
      menuTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
      menuTextureAtlas.load();
    } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }
  private void loadHighScoreGraphics() {
    if (recordTextureAtlas != null) {
      recordTextureAtlas.load();
    }

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/highscore/");

    recordTextureAtlas =
        new BuildableBitmapTextureAtlas(
            activity.getTextureManager(), 1024, 512, TextureOptions.BILINEAR);
    recordBackgroundTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            recordTextureAtlas, activity, "background.png");

    try {
      recordTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 0));
      recordTextureAtlas.load();
    } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }
  private void loadGameTypeGraphics() {
    if (gameTypeTextureAtlas != null) {
      gameTypeTextureAtlas.load();
    }

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/gametype/");
    gameTypeTextureAtlas =
        new BuildableBitmapTextureAtlas(
            activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);

    backgroundGameTypeTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTypeTextureAtlas, activity, "background.png");

    starGoldTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTypeTextureAtlas, activity, "goldStar.png");
    starWhiteTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTypeTextureAtlas, activity, "whiteStar.png");
    awesomeTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTypeTextureAtlas, activity, "awesome.png");
    lockTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTypeTextureAtlas, activity, "lock.png");
    playButtonTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTypeTextureAtlas, activity, "playButton.png");

    try {
      gameTypeTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(1, 1, 1));
      gameTypeTextureAtlas.load();
    } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }
  private void loadGameGraphics() {

    if (gameTextureAtlas != null) {
      gameTextureAtlas.load();
    }

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/game/");
    gameTextureAtlas =
        new BuildableBitmapTextureAtlas(
            activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);

    backgroundGameTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTextureAtlas, activity, "background.png");
    buttonOkTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTextureAtlas, activity, "button_ok.png");
    buttonNoTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTextureAtlas, activity, "button_no.png");
    lifeBarBorderTextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            gameTextureAtlas, activity, "bar_border.png");

    playerRegion =
        BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
            gameTextureAtlas, activity, "blackFish.png", 2, 1);

    try {
      gameTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
      gameTextureAtlas.load();
    } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }