Lgame引擎搭建和第一个例子

开源引擎发布地址:http://loon-simple.googlecode.com/ 

 

新建一个android工程,在manifest中对主Activity添加 android:configChanges="orientation|keyboardHidden"

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="gejw.android.Lgame"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="4" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/app_name"
            android:name=".LgameExampleActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
 

创建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

	}

}

 

 

 

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();
	}

}

你可能感兴趣的:(game)