0

我正在使用 Android Andengine 开发游戏。我正在使用相机宽度 720 和相机高度 480 但对于像 360 x 480 这样的低端设备,我使用的所有图像都被压缩。代码是

public Engine onLoadEngine() {
    mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, 
            new FillResolutionPolicy(), mCamera).setNeedsSound(true));
}

有什么解决办法吗?

4

1 回答 1

1

在 onCreateEngineOptions() 中,您应该指定 RatioResolutionPolicy。这会将您的活动扩展到所需的大小。您可以通过以下方法获取当前屏幕尺寸:

private DisplayMetrics getScreenResolutionRatio() {
    DisplayMetrics dm = new DisplayMetrics();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm;
}

然后指定您的 RatioResolutionPolicy:

public EngineOptions onCreateEngineOptions() {
    RatioResolutionPolicy policy = new RatioResolutionPolicy(getScreenResolutionRatio().width, getScreenResolutionRatio().height);
    return new EngineOptions(true, ScreenOrientation.PORTRAIT_SENSOR, policy, this.mCamera);
}
于 2012-10-03T09:42:30.970 回答