Android Open Source - Airplanes Play Menu Screen






From Project

Back to project page Airplanes.

License

The source code is released under:

GNU General Public License

If you think the Android project Airplanes 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.axnsan.airplanes.screens;
/* w w  w  .  ja v a  2 s  .c o m*/
import com.axnsan.airplanes.Airplanes;
import com.axnsan.airplanes.online.LoginScreen;
import com.axnsan.airplanes.util.FontManager;
import com.axnsan.airplanes.util.StringManager;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;

public class PlayMenuScreen implements Screen {
  private Stage stage;
  private Airplanes game;
  
  public PlayMenuScreen()
  {
    this.game = Airplanes.game;
  }
  
  @Override
  public void show() {
    game.input.clear();
    game.input.addProcessor(game);
  }

  @Override
  public void dispose() {
    Airplanes.game.input.removeProcessor(stage);
    
    if (stage != null)
      stage.dispose();
    
    stage = null;
  }

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

    if (stage != null) {
      stage.act(delta);
      stage.draw();
    }
    
    try {
      Thread.sleep(Math.max(0, (long) (Airplanes.MAX_FRAME_TIME - Gdx.graphics.getRawDeltaTime())));
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }

   @Override
  public void resize(int width, int height)
  {
    if (stage != null)
      stage.dispose();
    
    stage = new Stage();
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    
    Table table = new Table();
    table.setFillParent(true);
    stage.addActor(table);
    table.align(Align.top);
    table.padTop(h/5);
    

    game.setTextButtonFont(FontManager.getFontForHeight(h/20));
    /*if (game.state.activeGameMode != GameMode.None)
      table.add(resumeButton).pad(5).width(w/2).height(h/10);*/
    
    table.row();
    TextButton newGameButton = new TextButton(StringManager.getString("practice"), game.skin);
    newGameButton.addListener(new ClickListener() {
      @Override
      public void clicked(InputEvent event, float x, float y) 
      {
        game.setScreen(new PracticeStartScreen());
      }
    });
    table.add(newGameButton).pad(5).width(w/2).height(h/10);
    
    table.row();
    
    TextButton hotseatButton = new TextButton(StringManager.getString("hotseat"), game.skin);
    hotseatButton.addListener(new ClickListener() {
      @Override
      public void clicked(InputEvent event, float x, float y) 
      {
        game.setScreen(new HotseatStartScreen());
      }
    });
    table.add(hotseatButton).pad(5).width(w/2).height(h/10);
    
    table.row();
    
    TextButton onlineButton = new TextButton(StringManager.getString("online"), game.skin);
    onlineButton.addListener(new ClickListener() {
      @Override
      public void clicked(InputEvent event, float x, float y) 
      {
        game.setScreen(new LoginScreen());
      }
    });
    table.add(onlineButton).pad(5).width(w/2).height(h/10);
    
    table.row();
    
    /*TextButton testButton = new TextButton("test", game.skin);
    testButton.addListener(new ClickListener() {
      @Override
      public void clicked(InputEvent event, float x, float y) 
      {
        game.setScreen(new OnlineGameScreen());
      }
    });
    table.add(testButton).pad(5).width(w/2).height(h/10);
    
    table.row();*/
    
    TextButton backButton = new TextButton(StringManager.getString("main_exit"), game.skin);
    backButton.addListener(new ClickListener() {
      @Override
        public void clicked(InputEvent event, float x, float y)
        {
        game.exit();
        }
    });
    stage.addActor(backButton);
    backButton.setBounds(w/4, h/5, w/2, h/10);
    
    Airplanes.game.input.addProcessor(stage);
    Gdx.graphics.requestRendering();
  }
  @Override
  public void pause() {
  }

  @Override
  public void resume() {
  }

  @Override
  public void hide() {
    Airplanes.game.input.removeProcessor(stage);
  }

}




Java Source Code List

com.axnsan.airplanes.Airplanes.java
com.axnsan.airplanes.BaseGrid.java
com.axnsan.airplanes.GameConfiguration.java
com.axnsan.airplanes.GameState.java
com.axnsan.airplanes.GridRandomizer.java
com.axnsan.airplanes.Grid.java
com.axnsan.airplanes.GuardedScreen.java
com.axnsan.airplanes.HotseatMatchHandler.java
com.axnsan.airplanes.MainActivity.java
com.axnsan.airplanes.Main.java
com.axnsan.airplanes.MatchHandler.java
com.axnsan.airplanes.PlacementGrid.java
com.axnsan.airplanes.Plane.java
com.axnsan.airplanes.Player.java
com.axnsan.airplanes.PlayingGrid.java
com.axnsan.airplanes.online.ClientSocket.java
com.axnsan.airplanes.online.EventHandler.java
com.axnsan.airplanes.online.Game.java
com.axnsan.airplanes.online.LobbyScreen.java
com.axnsan.airplanes.online.LoginScreen.java
com.axnsan.airplanes.online.Message.java
com.axnsan.airplanes.online.Messages.java
com.axnsan.airplanes.online.OnlineGameScreen.java
com.axnsan.airplanes.online.OnlineMatchHandler.java
com.axnsan.airplanes.online.OnlineMenuScreen.java
com.axnsan.airplanes.online.OnlineSettingsScreen.java
com.axnsan.airplanes.online.SessionData.java
com.axnsan.airplanes.screens.BeginTurnScreen.java
com.axnsan.airplanes.screens.HotseatPlayersScreen.java
com.axnsan.airplanes.screens.HotseatScreen.java
com.axnsan.airplanes.screens.HotseatSettingsScreen.java
com.axnsan.airplanes.screens.HotseatStartScreen.java
com.axnsan.airplanes.screens.MainMenuScreen.java
com.axnsan.airplanes.screens.PlacementScreen.java
com.axnsan.airplanes.screens.PlayMenuScreen.java
com.axnsan.airplanes.screens.PracticeScreen.java
com.axnsan.airplanes.screens.PracticeSettingsScreen.java
com.axnsan.airplanes.screens.PracticeStartScreen.java
com.axnsan.airplanes.util.ActionManager.java
com.axnsan.airplanes.util.ActionResolver.java
com.axnsan.airplanes.util.BasicFontManager.java
com.axnsan.airplanes.util.Detector.java
com.axnsan.airplanes.util.DoubleTapDetector.java
com.axnsan.airplanes.util.DoubleTapListener.java
com.axnsan.airplanes.util.FontManagerInterface.java
com.axnsan.airplanes.util.FontManager.java
com.axnsan.airplanes.util.JavaXmlParser.java
com.axnsan.airplanes.util.Point2D.java
com.axnsan.airplanes.util.RandomizedQueue.java
com.axnsan.airplanes.util.StringManager.java
com.axnsan.airplanes.util.StringXmlParser.java
com.axnsan.airplanes.util.TTFFontManager.java
com.axnsan.airplanes.util.TapDetector.java
com.axnsan.airplanes.util.TapListener.java