2014-04-25 52 views
0

我正在開發一款帶有andengine的安卓遊戲。我使用AutoParallaxBackground重複背景。但我的背景圖片是不適合的screen.How解決同如何使AutoParallaxBackground適合屏幕

這裏是我的代碼提前

AutoParallaxBackground autoParallaxBackground=new AutoParallaxBackground(0, 0, 0, 10); 
    autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-25.0f, new Sprite(0, 0, backgroundTextureRegion , engine.getVertexBufferObjectManager()))); 
    gameScene.this.setBackground(autoParallaxBackground); 

感謝

回答

0

您可以嘗試縮放精靈只適合屏幕在創建ParallaxEntity之前,像這樣:

AutoParallaxBackground autoParallaxBackground=new AutoParallaxBackground(0, 0, 0, 10); 

Sprite mySprite = new Sprite(0, 0, backgroundTextureRegion , engine.getVertexBufferObjectManager()); 
mySprite.setScaleY(1.0f/(mySprite.getHeight()/CAMERA_HEIGHT)); 
mySprite.setScaleX(1.0f/(mySprite.getWidth()/CAMERA_WIDTH)); 

autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-25.0f, mySprite)); 
gameScene.this.setBackground(autoParallaxBackground); 
+0

我想調整autoparallaxBackground的大小..不是精靈 – varghesekutty