5

AndEngineGLES2を使用してAndroid用のゲームを書いています。すべてが正常に機能していました-背景画像があり、スプライトが動き回っていて、音楽さえありました-最近まで、ディスプレイが黒くなったときに何か新しいことを試しました(2つの異なるシーンを切り替えられるようにしたかった)。

それでもゲームを実行でき、エラーは表示されませんでした。ゲーム中に作成したすべてのログエントリが表示され、音楽も再生されていたため、ゲームが「正常に」実行されていることがわかりましたが、画像が表示されませんでした。何もない。全部黒。

したがって、この「エラー」が発生する前にすべてを元に戻すと、うまくいくと思いました。しかし、それでも画面は真っ黒です。

背景画像以外はすべてコメントアウトしてみましたが、何もありませんでした。

質問が多すぎない場合は、誰かがこの短いコードを調べて、そこで何が問題になっているのか教えてください。

これは私が使用する変数です:

private SmoothCamera camera;
private BitmapTextureAtlas bitmapTextureAtlas;  
private Scene scene;
private Sprite background;

EngineOptionsは変更したことがないので、問題ないはずです。

@Override
public EngineOptions onCreateEngineOptions() {
    float positionX = 80f; // horizontal (x) position of the camera
    float positionY = 280f; // vertical (y) position of the camera
    float velocityX = 200f; // velocity of the horizontal camera movement
    float velocityY = 200f; // velocity of the vertical camera movement
    float zoomFactor = 1f; // the camera's zoom Factor (standard := 1)
    this.camera = new SmoothCamera(positionX, positionY, this.getWindowManager().getDefaultDisplay().getWidth(), this.getWindowManager().getDefaultDisplay().getHeight(), velocityX, velocityY, zoomFactor);
    EngineOptions options = new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(this.camera.getWidth(), this.camera.getHeight()), this.camera);
    return options;
}

ここでは、TextureAtlasを作成し、背景画像をロードします。

@Override
protected void onCreateResources() {
    // create the TextureAtlas
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);

    // background
    this.background = new Sprite(0, 0, BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.bitmapTextureAtlas, this, "background.png", 0, 0, 1, 1), this.getVertexBufferObjectManager());
    this.mEngine.getTextureManager().loadTexture(this.bitmapTextureAtlas);
}

そして最後に、シーンがインスタンス化され、背景がアタッチされます。

@Override
protected Scene onCreateScene() {
    this.scene = new Scene();
    this.scene.attachChild(this.background);        
    return this.scene;
}

では、なぜこの小さなアクティビティが表示されないのでしょうか。私は忘れました:そのSimpleBaseGameActivity。

AndEngine GLES2はエミュレーターで実行されていないため、電話(Samsung Galaxy GIO)を使用する必要があり、別のマシンでアプリをテストすることはできません。

誰かが同様の問題に遭遇しましたか?どんな助けでも本当にありがたいです、そしてあなたの時間をありがとう!

  • クリストフ
4

1 に答える 1

1

問題はここにあると思います:

this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);

アトラスの次元は2の累乗であると想定されています。

于 2013-01-23T12:06:04.483 に答える