Android Open Source - Tetris-Evolution Main Menu






From Project

Back to project page Tetris-Evolution.

License

The source code is released under:

GNU General Public License

If you think the Android project Tetris-Evolution listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mygdx.states;
//from w ww. j av a 2s  .  co  m
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.moveTo;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.run;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.mygdx.modes.DarwinMode;

public class MainMenu implements Screen {

  private Stage stage;
  private Skin skin;
  private Table table;

  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    stage.act(delta);
    stage.draw();
  }

  @Override
  public void resize(int width, int height) {
    stage.setViewport(stage.getViewport());
    table.invalidateHierarchy();
  }

  @Override
  public void show() {
    stage = new Stage();

    Gdx.input.setInputProcessor(stage);

    skin = new Skin(Gdx.files.internal("res/ui/menuSkin.json"), new TextureAtlas("res/ui/atlas.pack"));

    table = new Table(skin);
    table.setFillParent(true);

    Label heading = new Label("Tetris->Evolution", skin, "big");
    heading.setFontScale(0.8f);

    TextButton buttonPlay = new TextButton("PLAY", skin, "big");
    buttonPlay.addListener(new ClickListener() {

      @Override
      public void clicked(InputEvent event, float x, float y) {
        stage.addAction(sequence(moveTo(0, stage.getHeight(), .5f), run(new Runnable() {

          @Override
          public void run() {
            ((Game) Gdx.app.getApplicationListener()).setScreen(new com.mygdx.game.Game(new DarwinMode()));
          }
        })));
      }
    });
    buttonPlay.pad(15);

    TextButton buttonInfo = new TextButton("INFO", skin);
    buttonInfo.addListener(new ClickListener() {

      @Override
      public void clicked(InputEvent event, float x, float y) {
        stage.addAction(sequence(moveTo(0, stage.getHeight(), .5f), run(new Runnable() {

          @Override
          public void run() {
            ((Game) Gdx.app.getApplicationListener()).setScreen(new Info());
          }
        })));
      }
    });
    buttonInfo.pad(15);

    table.add(heading).spaceBottom(100).row();
    table.add(buttonPlay).spaceBottom(15).row();
    table.add(buttonInfo).spaceBottom(15).row();

    stage.addActor(table);
  }

  @Override
  public void hide() {
    dispose();
  }

  @Override
  public void pause() {

  }

  @Override
  public void resume() {

  }

  @Override
  public void dispose() {
    stage.dispose();
    skin.dispose();
  }

}




Java Source Code List

com.mygdx.TetrisEvolution.android.AndroidLauncher.java
com.mygdx.TetrisEvolution.client.HtmlLauncher.java
com.mygdx.TetrisEvolution.desktop.DesktopLauncher.java
com.mygdx.blocks.Block.java
com.mygdx.blocks.BlocksBox.java
com.mygdx.blocks.Connect.java
com.mygdx.blocks.Level.java
com.mygdx.blocks.LogicScheme.java
com.mygdx.game.Game.java
com.mygdx.main.TetrisEvolution.java
com.mygdx.modes.DarwinMode.java
com.mygdx.modes.Mode.java
com.mygdx.renderer.ModeRenderer.java
com.mygdx.states.Info.java
com.mygdx.states.MainMenu.java
com.mygdx.states.ModeMenu.java
com.mygdx.states.Play.java
com.mygdx.states.Splash.java
com.mygdx.tools.GifDecoder.java
com.mygdx.tools.InvertXY.java
com.mygdx.tools.Resources.java
com.mygdx.util.Collision.java