我在使用andengine 开发的简单游戏中为菜单页面设置了bg。
我已将 bg 设置为
public class MenuActivity extends SimpleBaseGameActivity implements
IOnMenuItemClickListener {
private static int CAMERA_WIDTH = 480;
private static int CAMERA_HEIGHT = 800;
private Camera mCamera;
private ITextureRegion mBackgroundTextureRegion;
protected static final int MENU_RESET = 0;
protected static final int MENU_QUIT = MENU_RESET + 1;
private Font mFont;
protected MenuScene mMenuScene;
private Scene mScene;
@SuppressWarnings("deprecation")
@Override
public EngineOptions onCreateEngineOptions() {
final Display display = getWindowManager().getDefaultDisplay();
this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED,
new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT),
this.mCamera);
}
@Override
protected void onCreateResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
try {
ITexture backgroundTexture = new BitmapTexture(
this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/bg3.png");
}
});
backgroundTexture.load();
this.mBackgroundTextureRegion = TextureRegionFactory
.extractFromTexture(backgroundTexture);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
protected Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
Sprite backgroundSprite = new Sprite(0, 0,
this.mBackgroundTextureRegion, getVertexBufferObjectManager());
// this.mScene.attachChild(backgroundSprite);
this.mScene.setBackground(new SpriteBackground(backgroundSprite));
return this.mScene;
}
而且 bg 不适合屏幕,左右两端都有一些空格。这个怎么解决,?