三 最簡單的 AndEngine 程序框架

package com.example.AndEngineExample;ide

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.ui.activity.BaseGameActivity;ui

public class LineActivity extends BaseGameActivity{
private int CAMERA_WIDTH = 720; //攝像機寬度
private int CAMERA_HEIGHT = 480;//攝像機高度
private Camera mCamera;this

@Override
public Engine onLoadEngine() {
//建立攝像機
this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
//建立引擎選項
EngineOptions engineOptions=new EngineOptions(true, EngineOptions.ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera);
//建立引擎並返回它
return new Engine(engineOptions);
}對象

@Override
public void onLoadResources() {it

}io

@Override
public Scene onLoadScene() {
//註冊到週期更新回調
this.mEngine.registerUpdateHandler(new FPSLogger());
//創建場景對象
final Scene scene = new Scene(1);
//設置背景
scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));
//返回場景對象
return scene;
}class

@Override
public void onLoadComplete() {import

}date

相關文章
相關標籤/搜索