Libgdx桌面项目1

Libgdx桌面项目1_第1张图片

Libgdx桌面项目1_第2张图片

Libgdx桌面项目1_第3张图片

Libgdx桌面项目1_第4张图片

Libgdx桌面项目1_第5张图片



package com.xuefei.mygame;

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {
	public static void main(String[] args) {
		LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
		cfg.title = "MyGame";
		cfg.useGL20 = false;
		cfg.width = 800;
		cfg.height = 480;

		new LwjglApplication(new MyGame(), cfg);
	}
}


package com.xuefei.mygame;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;

public class MyGame implements ApplicationListener {

	Stage stage;
	Image wangnima01;

	@Override
	public void create() {
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		stage = new Stage(w, h, true);
		LabelStyle labelStyle = new LabelStyle(new BitmapFont(), Color.WHITE);
		Label label = new Label("FPS:", labelStyle);
		label.setName("fpsLabel");
		label.setY(0);
		label.setX(w - label.getTextBounds().width);
		stage.addActor(label);

	}

	@Override
	public void dispose() {
		stage.dispose();
	}

	@Override
	public void render() {
		Gdx.gl.glClearColor(0, 0, 0, 0);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		Label label = (Label) stage.getRoot().findActor("fpsLabel");
		label.setText("FPS:" + Gdx.graphics.getFramesPerSecond());
		label.setX(800 - label.getTextBounds().width);
		stage.act();
		stage.draw();
	}

	@Override
	public void resize(int width, int height) {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}
}

Libgdx桌面项目1_第6张图片


你可能感兴趣的:(游戏,android,引擎,libgdx)