Android游戏引擎libgdx使用教程15:TWL布局
Java代码
- package com.cnblogs.htynkn.game;
- import com.badlogic.gdx.ApplicationListener;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Files.FileType;
- import com.badlogic.gdx.graphics.GL10;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.twl.Layout;
- import com.badlogic.gdx.twl.TWL;
- import de.matthiasmann.twl.Button;
- public class TwlDemo implements ApplicationListener {
- private TWL twl;
- private SpriteBatch batch;
- @Override
- public void create() {
- batch = new SpriteBatch();
- Button button=new Button("Button");
- button.setTheme("button");
- Layout layout = new Layout();
- layout.add(button);
- twl=new TWL(batch, "data/twldemo.xml", FileType.Internal, layout);
- }
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
- @Override
- public void pause() {
- // TODO Auto-generated method stub
- }
- @Override
- public void render() {
- Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
- twl.render();
- }
- @Override
- public void resize(int width, int height) {
- // TODO Auto-generated method stub
- }
- @Override
- public void resume() {
- // TODO Auto-generated method stub
- }
- }