0
我最近開始使用Andengine.I在教程視頻的幫助下編寫了這段代碼。我想設置背景顏色並將一個球(top.png)添加到場景中。 當我運行程序來黑屏後不久模擬器拋出錯誤 我遇到了以下錯誤:UpdateThread中斷。別擔心 - 這個EngineDestroyedException很可能是預期的
UpdateThread interrupted. Don't worry - this EngineDestroyedException is most likely expected!
org.andengine.engine.Engine$EngineDestroyedException
at org.andengine.engine.Engine.throwOnDestroyed(Engine.java:574)
at org.andengine.engine.Engine.onTickUpdate(Engine.java:560)
at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
and my code:
package com.example.oyundeneme2;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.util.FPSLogger;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.opengl.texture.region.TiledTextureRegion;
import org.andengine.ui.activity.BaseGameActivity;
import android.view.Display;
public class OyunEkrani1 extends BaseGameActivity{
private static final int CAMERA_WIDTH=800;
private static final int CAMERA_HEIGHT=480;
private Camera myCamera;
private BitmapTextureAtlas myBackgroundTextureAtlas;
private TextureRegion myBackgroundTextureRegion;
//private Engine myEngine;
private Scene myScene;
private TiledTextureRegion myCircleFaceTextureRegion;
@Override
public EngineOptions onCreateEngineOptions() {
this.myCamera=new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
final Display myDisplay=getWindowManager().getDefaultDisplay();
EngineOptions FixedStepEngine=new EngineOptions(true,
ScreenOrientation.LANDSCAPE_FIXED,
new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), myCamera);
return FixedStepEngine;
}
@Override
public void onCreateResources(
OnCreateResourcesCallback pOnCreateResourcesCallback)
throws Exception {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
this.myBackgroundTextureAtlas=
new BitmapTextureAtlas(null,1024,512,TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.myCircleFaceTextureRegion =BitmapTextureAtlasTextureRegionFactory.createTiledFrom
Asset(this.myBackgroundTextureAtlas, this, "top.png", 60, 60, 0, 0); // 64x32
this.mEngine.getTextureManager().loadTexture(this.myBackgroundTextureAtlas);
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
throws Exception {
mEngine.registerUpdateHandler(new FPSLogger());
myScene = new Scene();
myScene.setBackground(new Background(0.59804f, 0.5274f, 0.5784f));
}
@Override
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
// TODO Auto-generated method stub
}
}
什麼問題呢?你必須通過回調函數pOnCreateSceneCallback.onCreateSceneFinished(scene)返回你的場景,並且返回你的onLoadResourcers(),即pOnCreateResourcesCallback.onCreateResourcesFinished(); – Rama
如果您要擴展BaseGameActivity,則必須實現對所有重寫方法的回調 – Rama