【发布时间】:2015-10-30 08:49:46
【问题描述】:
我是 Android 游戏开发的新手,我遇到了关于屏幕图像背景的问题。
这是我扩展SimpleBaseGameActivity的完整课程代码
更新的相机宽度和高度对应于图像尺寸
private final int CAMERA_WIDTH = 480;//800;
private final int CAMERA_HEIGHT = 836; //1280;
private Camera mCamera;
//Background variables
private TextureRegion region;
private Scene mScene;
@Override
public EngineOptions onCreateEngineOptions() {
this.mCamera = new Camera(0,0,CAMERA_WIDTH,CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.PORTRAIT_SENSOR, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera);
}
@Override
protected void onCreateResources() throws IOException {
BitmapTextureAtlas atlas = new BitmapTextureAtlas(this.getTextureManager(),CAMERA_WIDTH+CAMERA_WIDTH,CAMERA_HEIGHT+CAMERA_HEIGHT);
this.region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlas,this,"snow_bg.png",0,0);
atlas.load();
}
@Override
protected Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
Sprite sprite = new Sprite(0,0,region,this.getVertexBufferObjectManager());
this.mScene.setBackground(new SpriteBackground(sprite));
return this.mScene;
}
我面临的问题是背景图片,它不是全屏的。我一直在寻找如何在AndEngine 中拉伸图像背景,但我没有找到任何好的资源。
这是屏幕截图。
但图像全屏视图是
请给我一些建议我应该怎么做或示例代码来实现我的目标。
提前致谢。
【问题讨论】:
标签: android box2d andengine game-engine