Libgdx1

把gdx.jar   gdx-backend-android.jar以及文件夹  armeabi-v7a和 armeabi复制到新建工程的libs中。

MainActivity.java

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;

 

public class MainActivity extends AndroidApplication {   

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        initialize(new FirstGame(), false);

    }

}

FirstGame.java


package com.xuefei.libgdx1;

import javax.microedition.khronos.opengles.GL10;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class FirstGame implements ApplicationListener {

 // 绘图用的SpriteBatch

 private SpriteBatch batch;
 // 纹理
 private Texture texture;

 @Override
 public void create() {

  batch = new SpriteBatch(); // 实例化
  texture = new Texture(Gdx.files.internal("android.png"));

//图片放在assets下

 }

 @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); // 清屏

  batch.begin();
  batch.draw(texture, 20, 10);
  batch.end();

 }

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

  // TODO Auto-generated method stub

 }

 @Override
 public void resume() {

  // TODO Auto-generated method stub

 }

}

Libgdx1_第1张图片


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