org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy Java Examples
The following examples show how to use
org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlipGameActivity.java From tilt-game-android with MIT License | 5 votes |
@Override public EngineOptions onCreateEngineOptions() { Point size = new Point(); if (Build.VERSION.SDK_INT >= 17) { getWindowManager().getDefaultDisplay().getRealSize(size); } else { DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); size.x = displayMetrics.widthPixels; size.y = displayMetrics.heightPixels; } float desiredRatio = (float) (1080.0 / 1920.0); final float realRatio = size.x / size.y; int measuredWidth; int measuredHeight; if (realRatio < desiredRatio) { measuredWidth = size.x; measuredHeight = Math.round(measuredWidth / desiredRatio); } else { measuredHeight = size.y; measuredWidth = Math.round(measuredHeight * desiredRatio); } _scale = measuredWidth / 1080.0f; _cameraWidth = measuredWidth; _cameraHeight = measuredHeight; return new EngineOptions( true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(1080, 1920), new Camera(0, 0, _cameraWidth, _cameraHeight)); }
Example #2
Source File: AndEngineActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public EngineOptions onCreateEngineOptions() { mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); IResolutionPolicy resolutionPolicy = new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT); return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, resolutionPolicy, mCamera); }
Example #3
Source File: GameActivity.java From sopa with Apache License 2.0 | 5 votes |
@Override public EngineOptions onCreateEngineOptions() { camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera); engineOptions.getAudioOptions().setNeedsMusic(true); return engineOptions; }