2012-01-16 44 views
1

我試圖更新我的項目與AndEngine GLES2運行,但我有一些問題。我找到了一篇文章,說明要改變什麼,但它仍然無法運作。這正是我在做什麼:AndEngine導入GLES2項目未運行

onCreateEngineOptions()

@Override 
public EngineOptions onCreateEngineOptions() { 
    Toast.makeText(this, "Touch the screen to add Logo.", Toast.LENGTH_LONG).show(); 
    CAMERA_WIDTH = getWindow().getWindowManager().getDefaultDisplay().getWidth(); 
    CAMERA_HEIGHT = getWindow().getWindowManager().getDefaultDisplay().getHeight(); 

    final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); 


    final EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera); 
    engineOptions.getTouchOptions().setNeedsMultiTouch(false); 
    return engineOptions; 
} 

onCreateResources()

public void onCreateResources() { 

    this.mBitmapTextureAtlas = new BitmapTextureAtlas(4096, 4096, TextureOptions.BILINEAR_PREMULTIPLYALPHA); 

    this.mFont = new Font(this.mBitmapTextureAtlas, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL), 25, true, Color.BLACK); 

    this.mEngine.getTextureManager().loadTexture(this.mBitmapTextureAtlas); 
    this.mEngine.getFontManager().loadFont(this.mFont); 


    this.firstSprite = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "1.png", 0, 113); // 113x100 
      // 36 other sprites, that's why I'm creating BitmapTextureAtlas with these size 

    this.mEngine.getTextureManager().loadTexture(this.mBitmapTextureAtlas); 
} 

onCreateScene()

@Override 
public Scene onCreateScene() { 
    this.mEngine.registerUpdateHandler(new FPSLogger()); 

    this.mScene = new Scene(); 
    this.mScene.setBackground(new Background(4, 4, 4)); 
    this.mScene.setOnSceneTouchListener(this); 

    this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false); 

    CAMERA_WIDTH = getWindow().getWindowManager().getDefaultDisplay().getWidth(); 
    CAMERA_HEIGHT = getWindow().getWindowManager().getDefaultDisplay().getHeight(); 

    final IAreaShape ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2); 
    final IAreaShape roof = new Rectangle(0, 0, CAMERA_WIDTH, 2); 
    final IAreaShape left = new Rectangle(0, 0, 2, CAMERA_HEIGHT); 
    final IAreaShape right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT); 

    final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f); 
    PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.KinematicBody, wallFixtureDef); 
    PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.KinematicBody, wallFixtureDef); 
    PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.KinematicBody, wallFixtureDef); 
    PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.KinematicBody, wallFixtureDef); 

    this.mScene.attachChild(ground); 
    this.mScene.attachChild(roof); 
    this.mScene.attachChild(left); 
    this.mScene.attachChild(right); 

    this.mScene.registerUpdateHandler(this.mPhysicsWorld); 
    this.mScene.setOnAreaTouchListener(this); 

    final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(1, 0.5f, 1); 

    //Sprite 1 
    Sprite face = new Sprite(CAMERA_WIDTH/2, 50, this.firstSprite); 
    face.setUserData("petrol"); 
    Body body = PhysicsFactory.createCircleBody(this.mPhysicsWorld, face, BodyType.DynamicBody, objectFixtureDef); 
    this.mScene.registerTouchArea(face); 
    this.mScene.attachChild(face); 
    this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, body, true, true)); 
      // 36 sprites.... 
return this.mScene; 
    } 

而問題是,當我開始這個活動它沒有顯示精靈的非即使我將其更改爲白色,屏幕保持黑色。

所以,任何想法是我的錯誤和我做錯了什麼。 (在移動到AndEngine GLES2之前,除了Android Honeycomb之外,一切正在運行,現在我正在使用Android 2.3.4運行的HTC EVO 3d上測試此項目)。

在此先感謝!

回答

3

我不知道如果這是你的問題 - 我有類似的問題,我說這個

@Override 
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception { // 
    // TODO Auto-generated method stub 

    pOnPopulateSceneCallback.onPopulateSceneFinished(); 
}