Detect Screen Resolution
Function
Detect the native resolution of the device and use for screen and camera.
Remarks
Depending on type of application might not be advisable to do. You cant use hardcoded locations for sprites or other objects, rather calculate in relation to detected screensize. Also, AndEngine scales the image quite well so often it will not be necessary to render in the exact resolution of the device.
Snippet
public Engine onLoadEngine() { final Display display = getWindowManager().getDefaultDisplay(); int cameraWidth = display.getWidth(); int cameraHeight = display.getHeight(); String deb = String.format("Screen: %d / %d",cameraWidth,cameraHeight); Log.d("Debug:", deb); this.mCamera = new Camera(0, 0, cameraWidth,cameraHeight); return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(cameraWidth, cameraHeight), this.mCamera)); }
page revision: 1, last edited: 10 Feb 2011 16:26