libgdx 像素鸟 游戏 go on 第一个欢迎界面



最近准备完成 像素鸟的游戏设计,慢慢来了。


go on!!!!!!!


简单的一个界面:渲染一张图即可。

显示如下:

libgdx 像素鸟 游戏 go on 第一个欢迎界面_第1张图片



代码如下:

package com.example.bird;


import android.util.Log;


import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task;


public class InfoScreen extends ScreenAdapter {


SpriteBatch Batch;
private TextureAtlas atlas;
private Sprite sprite;
FirstGame Gm;


public InfoScreen(FirstGame tGm) {
// TODO Auto-generated constructor stub
this.Gm = tGm;
Batch = new SpriteBatch();
atlas = new TextureAtlas(Gdx.files.internal("data/show.pack"));
sprite = atlas.createSprite("splash");
sprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
new Timer().scheduleTask(new Task() {


@Override
public void run() {
// TODO Auto-generated method stub
Log.i("lxmlxm", "timer ok!");
Gm.setScreen(new MainMenuScreen(Gm));
}
}, 3);


}


@Override
public void render(float delta) {
// TODO Auto-generated method stub
super.render(delta);
Batch.begin();
sprite.draw(Batch);
Batch.end();


}


@Override
public void resume() {
// TODO Auto-generated method stub
super.resume();
}


@Override
public void pause() {
// TODO Auto-generated method stub
super.pause();
Gdx.input.setInputProcessor(null);
}


@Override
public void hide() {
// TODO Auto-generated method stub
super.hide();
}


@Override
public void dispose() {
// TODO Auto-generated method stub
super.dispose();
Batch.dispose();
atlas.dispose();


}


}


你可能感兴趣的:(android,源码分析,libgdx,bird,Flappy,像素鸟)