Android Open Source - Infinite Screen Main Menu






From Project

Back to project page Infinite.

License

The source code is released under:

GNU General Public License

If you think the Android project Infinite 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.detel.infinite.screens;
/*from w  w  w . j a  v a2 s .c  o  m*/
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.math.Vector2;
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.detel.infinite.Infinite;

/**
 * Created by Derick on 4/14/14.
 */
public class ScreenMainMenu extends ScreenBase{

    private Infinite infinite;

    private Stage stage;
    private static final Vector2 viewPort = new Vector2(20f,12f);

    private FileHandle skinHandle = Gdx.files.internal("data/uiskin.json");

    float centerPad;
    float itemWidth;
    float itemHeight;

    public ScreenMainMenu(Infinite infinite){
        this.infinite = infinite;

        centerPad = Gdx.graphics.getHeight() * 1/27;
        itemWidth = Gdx.graphics.getWidth() * 1/2;
        itemHeight = Gdx.graphics.getHeight() * 1/8;
    }

    @Override
    public void show(){

        //Create

        stage = new Stage();
        Skin skin = new Skin(skinHandle);

        Label titleLabel = new Label("Infinite", skin);

        TextButton startButton = new TextButton("Start", skin);

        //Layout

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

        table.add(titleLabel).center().pad(centerPad);
        table.row().height(itemHeight);
        table.add(startButton).width(itemWidth).pad(5f);
        table.row().height(itemHeight);
        stage.addActor(table);

        //Listeners

        startButton.addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event,float x,float y){
                System.out.println("Clicked");
                infinite.setScreen(new ScreenGame(infinite));
            }
        });

        Gdx.input.setInputProcessor(stage);

    }

    @Override
    public void render(float v){

        Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1f);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        stage.act(v);
        stage.draw();

    }

    @Override
    public void resize(int i, int i2){

    }

}




Java Source Code List

com.detel.infinite.Infinite.java
com.detel.infinite.MainActivity.java
com.detel.infinite.Main.java
com.detel.infinite.controllers.CameraController.java
com.detel.infinite.controllers.ChunkController.java
com.detel.infinite.controllers.EnemyController.java
com.detel.infinite.controllers.KnifeController.java
com.detel.infinite.controllers.PlayerController.java
com.detel.infinite.controllers.WorldController.java
com.detel.infinite.models.BlockAir.java
com.detel.infinite.models.Block.java
com.detel.infinite.models.Chunk.java
com.detel.infinite.models.Enemy.java
com.detel.infinite.models.Player.java
com.detel.infinite.models.ThrowingKnife.java
com.detel.infinite.models.World.java
com.detel.infinite.screens.ScreenBase.java
com.detel.infinite.screens.ScreenGameOver.java
com.detel.infinite.screens.ScreenGame.java
com.detel.infinite.screens.ScreenMainMenu.java
com.detel.infinite.screens.ScreenPause.java
com.detel.infinite.views.WorldRenderer.java