Andengine半黑屏

时间:2015-02-15 15:11:36

标签: android camera andengine

我正在尝试开发一款带引擎的游戏。我创建了一个相机,设置它的边界和尺寸(720X1280)但是当我运行应用程序时,我只看到屏幕的顶部,其余部分是黑色。

@Override
public EngineOptions onCreateEngineOptions() {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    float ratio = (float) size.y / (float) size.x;
    GameSettings.CAMERA_HEIGHT = (int) (GameSettings.CAMERA_WIDTH / ratio);
    Constants.camera = new SmoothCamera(0, 0, GameSettings.CAMERA_WIDTH, GameSettings.CAMERA_HEIGHT, 500, 500, 0.1f);

    Constants.camera.setBoundsEnabled(true);
    EngineOptions en_op = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(GameSettings.CAMERA_WIDTH, GameSettings.CAMERA_HEIGHT), Constants.camera);
    en_op.getAudioOptions().setNeedsSound(true);
    en_op.getRenderOptions().setDithering(true);
    return en_op;
}

@Override
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("graph/");
    MyResources.SplashTextureRegion = MyResources.getTextureRegion(this, "splash.jpg", 720, 1280);
    pOnCreateResourcesCallback.onCreateResourcesFinished();
}

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

好的家伙我发现......这是比率计算。我需要多个宽度,比例不得偏离