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;
}
また、背景が画面に収まらず、左端と右端の両方に空白があります。これを解決する方法は?