【发布时间】:2015-02-05 05:25:06
【问题描述】:
最近我开始研究 AndEngine。
我正在尝试设置场景的背景图像。
但由于某种原因,背景图像没有完全填满屏幕。
有什么建议和帮助吗?
这是我的源代码:
public class MainActivity extends BaseGameActivity {
Scene sc;
protected final static int cam_wid = 320;
protected final static int cam_heigh = 456;
BitmapTextureAtlas texAtlas;
ITextureRegion texRegion;
@Override
public EngineOptions onCreateEngineOptions() {
// TODO Auto-generated method stub
Camera ca = new Camera(0, 0, cam_wid, cam_heigh);
EngineOptions en = new EngineOptions(true,
ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(
cam_wid, cam_heigh), ca);
return en;
}
@Override
public void onCreateResources(
OnCreateResourcesCallback pOnCreateResourcesCallback)
throws Exception {
// TODO Auto-generated method stub
load();
pOnCreateResourcesCallback.onCreateResourcesFinished();
}
private void load() {
// TODO Auto-generated method stub
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
texAtlas = new BitmapTextureAtlas(getTextureManager(), 256, 512);
texRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
texAtlas, this, "imagery.png", 0, 0);
texAtlas.load();
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
throws Exception {
// TODO Auto-generated method stub
this.sc = new Scene();
Sprite s = new Sprite(0, 0, cam_wid, cam_heigh, texRegion,
this.mEngine.getVertexBufferObjectManager());
SpriteBackground sb = new SpriteBackground(s);
sc.setBackground(sb);
pOnCreateSceneCallback.onCreateSceneFinished(sc);
}
@Override
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
// TODO Auto-generated method stub
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
}
【问题讨论】:
标签: android opengl-es opengl-es-2.0 andengine