Book Image

LibGDX Game Development By Example

By : James Cook
Book Image

LibGDX Game Development By Example

By: James Cook

Overview of this book

Table of Contents (18 chapters)
LibGDX Game Development By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Start screen and disposal


So, here we are back with Flappee Bee. The first thing we should tackle is having a Start screen, or menu screen, depending on what you want to call it. This Screen class will be built entirely with Scene2d.ui components and you will be mesmerized by how awesome all this is.

First things first; let's decide what we will have on our start screen. We will need a play button and some text, perhaps also a title image on the screen.

Let's create our StartScreen class and add the Stage classes to it:

public class StartScreen extends ScreenAdapter {

  private static final float WORLD_WIDTH = 480;
  private static final float WORLD_HEIGHT = 640;

  private Stage stage;

  public void show() {
    stage = new Stage(new FitViewport(WORLD_WIDTH, WORLD_HEIGHT));
    Gdx.input.setInputProcessor(stage);
  }

  public void resize(int width, int height) {
    stage.getViewport().update(width, height, true);
  }

  public void render(float delta) {
    stage.act(delta);
    stage...