android游戏开发引擎LIBGDX环境搭建
更详细内容请访问:http://www.apkbus.com/android-57372-1-1.html
1.获取LIBGDX:https://github.com/libgdx/libgdx/releases 笔者的版本是:Libgdx 0.9.9 Xamarin Release
2.新建一个android工程
3.复制 gdx.jar gdx-backend-android.jar armeabi(文件夹) armeabi-v7a(文件夹) 到libs下
4.重写MainActivity文件
package com.deity.libgdx; import com.badlogic.gdx.backends.android.AndroidApplication; import android.os.Bundle; import android.view.Menu; public class MainActivity extends AndroidApplication { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); initialize(new FirstGame(), false); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
FirstGame类:
package com.deity.libgdx; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.graphics.g2d.SpriteBatch; public class FirstGame implements ApplicationListener { private SpriteBatch batch; @Override public void create() { // TODO Auto-generated method stub batch = new SpriteBatch(); //实例化 } @Override public void dispose() { // TODO Auto-generated method stub } @Override public void pause() { // TODO Auto-generated method stub } @Override public void render() { // TODO Auto-generated method stub } @Override public void resize(int arg0, int arg1) { // TODO Auto-generated method stub } @Override public void resume() { // TODO Auto-generated method stub } }
到这里,运行app,会发现,界面黑屏,环境已经搭建完成