Search code examples
androidandenginesizing

Scaling AndEngine game to different device sizes


Currently I am using this method to "scale" the screen size of devices, and it works perfectly on my Nexus 5 (5" size) but on my Nexus 7 2012 (7" screen size) The width seems to be perfect I'd say, but the height is horrible. There's like 2 inches of black space on the very bottom.

@Override
public EngineOptions onCreateEngineOptions() {

    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    camera = new FollowCamera(0, 0, Constants.CW, Constants.CH);
    IResolutionPolicy resolutionPolicy = new FillResolutionPolicy();
    EngineOptions engineOptions = new EngineOptions(true,
            ScreenOrientation.PORTRAIT_FIXED, resolutionPolicy, camera);
    engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);
    engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
    return engineOptions;
}

And here are my constants

public static final int CW = 480; //Width of Game
public static final int CH = 800; //Height of Game

Could you guys help me fix this? Thank you.


Solution

  • I have given a similar answer in another link. So, hope my answer in the below link helps you:

    andengine activity bg not fit the screen