开源引擎发布地址:
新建一个android工程,在manifest中对主Activity添加 android:configChanges="orientation|keyboardHidden"
创建GameScreen.java和Main.java 代码如下:
package gejw.android.Lgame;import org.loon.framework.android.game.core.graphics.Screen;import org.loon.framework.android.game.core.graphics.opengl.GLEx;import org.loon.framework.android.game.core.graphics.opengl.LTexture;import org.loon.framework.android.game.core.input.LTouch;import org.loon.framework.android.game.core.timer.LTimerContext;import android.util.Log;public class GameScreen extends Screen { private LTexture images; /** * 初次载入的时候调用 * */ @Override public void onLoad() { // 记录日志 Log.d("LGAMETEST1", "here it is onLoad"); LTexture.AUTO_LINEAR();// assets放置资源文件 images = new LTexture("assets/background.jpg");// 设置当前Screen的背景图片 setBackground(images); // 背景音乐,"main.mp3"文件放置在assets文件夹下面 // playAssetsMusic("main.mp3", true); } @Override public void alter(LTimerContext context) { // TODO Auto-generated method stub } @Override public void draw(GLEx ex) { // TODO Auto-generated method stub } @Override public void touchDown(LTouch lTouch) { // TODO Auto-generated method stub } @Override public void touchMove(LTouch lTouch) { // TODO Auto-generated method stub } @Override public void touchUp(LTouch lTouch) { // TODO Auto-generated method stub }}
View Code
package gejw.android.Lgame;import org.loon.framework.android.game.LGameAndroid2DActivity;public class LgameExampleActivity extends LGameAndroid2DActivity { @Override public void onGamePaused() { // TODO Auto-generated method stub } @Override public void onGameResumed() { // TODO Auto-generated method stub } @Override public void onMain() { // TODO Auto-generated method stub // 设置是否为横屏 initialization(true, LMode.Fill); setScreen(new GameScreen()); setShowLogo(false); setShowFPS(true); showScreen(); }}
原文链接