Android Open Source - Infinite Screen Game Over






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  . ja  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;
import com.detel.infinite.models.World;
import com.detel.infinite.views.WorldRenderer;

/**
 * Created by Derick on 5/6/14.
 */
public class ScreenGameOver extends ScreenBase{

    private Infinite infinite;
    private World world;
    private WorldRenderer worldRenderer;

    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 ScreenGameOver(Infinite infinite, World world, WorldRenderer worldRenderer){
        this.infinite = infinite;
        this.world = world;
        this.worldRenderer = worldRenderer;

        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 scoreLabel = new Label("Score: " + String.valueOf(world.getScore()), skin);

        TextButton startButton = new TextButton("Retry", skin);
        TextButton scoreButton = new TextButton("Main Menu", skin);



        //Layout

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

        table.add(scoreLabel).center().pad(centerPad);
        table.row().height(itemHeight);
        table.add(startButton).width(itemWidth).pad(5f);
        table.row().height(itemHeight);
        table.add(scoreButton).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));
            }
        });

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

        Gdx.input.setInputProcessor(stage);

    }

    @Override
    public void render(float v){

        worldRenderer.render();

        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