2012-06-07 10 views
5

私は自分のシーンの背景を設定したいと思っていますが、どうすればいいですか?私はこれについてたくさん読んでいたが、私はこれをすることはできない。 Andengineと私のスタートは、私の問題のための正確な情報が見つけにくい、すべてが主観的です。Andengineのシーンに背景を追加するAndroid

まあ、私はシーン内にスプラッシュ画面を実装し、すべてのリソースとシーンをロードしています。 (https://sites.google.com/site/matimdevelopment/splash-screen---easy-way)

次に、私はmenuSceneにBackgroundを設定する必要があります。私はTextureRegionと各バックグラウンドを作成するBitmapTextureAtlas。

宣言テクスチャ::私はこれを行う

//Fondo escenas 
private TextureRegion menuBgTexture; 
private BitmapTextureAtlas menuBackgroundTexture; 

負荷資源及び(スプラッシュが終了したときに彼らはonPopulateSceneで呼ばれている)シーンをロード

public void loadResources() 
{ 
    //FondoMenu 
    menuBackgroundTexture = new BitmapTextureAtlas(null, 480, 320, TextureOptions.DEFAULT); 
    menuBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.menuBackgroundTexture, this, "menubg.png", 0, 0); 
    //Cargamos los fondos 
    mEngine.getTextureManager().loadTexture(this.menuBackgroundTexture); 

} 

private void loadScenes() 
{ 
    //Menú 
    menuScene = new Scene(); 
    final float centerX = (CAMERA_WIDTH - menuBgTexture.getWidth())/2; 
    final float centerY = (CAMERA_HEIGHT - menuBgTexture.getHeight())/2; 
    SpriteBackground bg = new SpriteBackground(new Sprite(centerX, centerY, menuBgTexture)); 
    menuScene.setBackground(bg); 
    //menuScene.setBackground(new Background(50, 0, 0)); 
    //Options 
    optionsScene = new Scene(); 
    //Juego 
    gameScene = new Scene(); 
    //Pausa 
    pauseScene = new Scene(); 
    //Gameover 
    gameOverScene = new Scene(); 
} 

負荷リソースがない、ラインのエラーが、loadScenesを示し: SpriteBackground bg = new SpriteBackground(新しいスプライト(centerX、centerY、menuBgTexture));

新しい属性(ISpriteVertexBufferObject)を設定する必要がありますが、これは何ですか? VBOManagerオブジェクトの

+0

どのGLESを使用していますか? GLES2?私はGLES2のonCreateResources()を持っています。なぜNicolas Gramlichがこのような重要な機能の名前を変更することにしたのか、そしてなぜドキュメンテーションなしでエンジン/ライブラリを作成したのかわかりません。誰でも助けてもらえますか? – shailenTJ

+1

ドキュメンテーションになったときに彼が何を考えていたかを誰が知っていますか?そして、神はエンジンに関するフォーラムでこのことについて何も言いません。もしあなたがソースコードを読んで作業しなければならないと言われたら、うーん、良いですが、その事のためのソースコードには何のコメントもありません。それは残念ながら実際にはちょっとしたオープンソースエンジンなのです.D – Spider

+0

私も同様の問題に直面しています...自分の背景を設定することができません。ここにコードです..menuBackgroundTexture = new BitmapTextureAtlas null、2 * CAMERA_WIDTH、2 * CAMERA_HEIGHT、TextureOptions.DEFAULT); \t menuBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.menuBackgroundTexture、this、 "land.png"、0、0); \t \t SpriteBackground bg = new SpriteBackground(新しいスプライト(0、0、menuBgTexture、this.getVertexBufferObjectManager())); \t \t mScene.setBackground(bg); ....誰でも助けてくれますか? – Rahul

答えて

2

this.getVertexBufferObjectManager(); 
+0

ありがとう!うまく動作します:) bgのイメージは、画面上のすべての領域を埋めるわけではない、私は何かを追加する必要がありますか? – Genaut

+0

エンジンをどのように初期化していますか?どのサイズ、どのようなResolutionPolicy – jmroyalty

+0

まあ、私は今エンジンから始まっているので、私はまだそれについては分かりませんが、私の "onCreateEngine"は: カメラ=新しいカメラ(0、0、CAMERA_WIDTH、CAMERA_HEIGHT);EngineOptions engineOptions = new EngineOptions(true、ScreenOrientation。LANDSCAPE_FIXED、新しいFillResolutionPolicy()、カメラ)。 プライベートfinal int CAMERA_WIDTH = 720; プライベートfinal int CAMERA_HEIGHT = 480; 私の画像サイズは320x480です – Genaut

1

を使用し、私も私のゲームと同じ問題がありました。解決策は、カメラと同じ寸法の背景画像を持つことです。たとえば、カメラが800X480の場合、画像も同じ寸法でなければなりません。また、BitmapTextureAtlasの係数の次元を2にします。あなたの場合、512ピクセルx 512ピクセルです。希望が役立ちます。

乾杯!

関連する問題