Thread LWJGL Application

时间:2018-05-29 10:49:06

标签: java exception-handling libgdx flappy-bird-clone

--------------- Stack.class -----------------

  // Source code recreated from a .class file by IntelliJ IDEA
  // (powered by Fernflower decompiler)
  //

package java.util;

public class Stack<E> extends Vector<E> {
private static final long serialVersionUID = 1224463164541339165L;

public Stack() {
}

public E push(E var1) {
    this.addElement(var1);
    return var1;
}

public synchronized E pop() {
    int var2 = this.size();
    Object var1 = this.peek();
    this.removeElementAt(var2 - 1);
    return var1;
}

public synchronized E peek() {
    int var1 = this.size();
    if (var1 == 0) {
        throw new EmptyStackException();  

//首先来     java.util.Stack.peek(Stack.java:102)//

    } else {
        return this.elementAt(var1 - 1);
    }
}

public boolean empty() {
    return this.size() == 0;
}

public synchronized int search(Object var1) {
    int var2 = this.lastIndexOf(var1);
    return var2 >= 0 ? this.size() - var2 : -1;
}
}

--------------------- GameStateManager.java --------------------

package com.flappy.game.States;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import java.util.Stack;


public class GameStateManager {
private Stack<State> states;

public GameStateManager(){
    states = new Stack<State>();
}

public void push(State state){
    states.push(state);
}

public void pop(){
    states.pop();
}

public void set(State state){
    states.pop();
    states.push(state);
}

public void update(float dt){
    states.peek().update(dt); 

//秒     com.flappy.game.States.GameStateManager.update(GameStateManager.java:28)//

}

public void render(SpriteBatch sb){
    states.peek().render(sb);
}
}

---------- ---------- Flappy.java

package com.flappy.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.flappy.game.States.GameStateManager;
import com.flappy.game.States.MenuState;

public class Flappy extends ApplicationAdapter {

public static final int WIDTH  =  480;
public static final int HEIGHT  =  800;
public static final  String TITLE  = "Cioara" ;
private GameStateManager gsm;
private SpriteBatch batch ;



@Override
public void create () {
    batch = new SpriteBatch();
    gsm = new GameStateManager();
    Gdx.gl.glClearColor(1, 0, 0, 1);

}

@Override
public void render () {

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    gsm.update(Gdx.graphics.getDeltaTime()); 

//在        com.flappy.game.Flappy.render(Flappy.java:33)//

    gsm.render(batch);
}
}

--------------- LwjglApplication.java ----------------

https://pastebin.com/6gRkiz0y

首先在第225行com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:225)

第126行第二名  com.badlogic.gdx.backends.lwjgl.LwjglApplication $ 1.run(LwjglApplication.java:126)

结果应该是一个400x800像素的屏幕,背景和中间的按钮

根据本教程使用libGDX框架开发的应用程序:https://www.youtube.com/watch?v=rzBVTPaUUDg&list=PLZm85UZQLd2TPXpUJfDEdWTSgszionbJy&index=1

0 个答案:

没有答案