Java源码示例:org.andengine.engine.options.EngineOptions
示例1
@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));
}
示例2
private void applyEngineOptions() {
final EngineOptions engineOptions = this.mEngine.getEngineOptions();
if (engineOptions.isFullscreen()) {
ActivityUtils.requestFullscreen(this);
}
if (engineOptions.getAudioOptions().needsMusic() || engineOptions.getAudioOptions().needsSound()) {
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
switch (engineOptions.getScreenOrientation()) {
case LANDSCAPE_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case LANDSCAPE_SENSOR:
if (SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
break;
case PORTRAIT_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case PORTRAIT_SENSOR:
if (SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
break;
}
}
示例3
@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);
}
示例4
private void applyEngineOptions() {
final EngineOptions engineOptions = this.mEngine.getEngineOptions();
if(engineOptions.isFullscreen()) {
ActivityUtils.requestFullscreen(this);
}
if(engineOptions.getAudioOptions().needsMusic() || engineOptions.getAudioOptions().needsSound()) {
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
switch(engineOptions.getScreenOrientation()) {
case LANDSCAPE_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case LANDSCAPE_SENSOR:
if(SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
break;
case PORTRAIT_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case PORTRAIT_SENSOR:
if(SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
break;
}
}
示例5
@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;
}
示例6
public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
super(pEngineOptions);
this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
示例7
public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
super(pEngineOptions);
this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
示例8
public Engine(final EngineOptions pEngineOptions) {
/* Initialize Factory and Manager classes. */
BitmapTextureAtlasTextureRegionFactory.reset();
SoundFactory.onCreate();
MusicFactory.onCreate();
FontFactory.onCreate();
this.mVertexBufferObjectManager.onCreate();
this.mTextureManager.onCreate();
this.mFontManager.onCreate();
this.mShaderProgramManager.onCreate();
/* Apply EngineOptions. */
this.mEngineOptions = pEngineOptions;
if (this.mEngineOptions.hasEngineLock()) {
this.mEngineLock = pEngineOptions.getEngineLock();
} else {
this.mEngineLock = new EngineLock(false);
}
this.mCamera = pEngineOptions.getCamera();
/* Touch. */
if (this.mEngineOptions.getTouchOptions().needsMultiTouch()) {
this.setTouchController(new MultiTouchController());
} else {
this.setTouchController(new SingleTouchController());
}
/* Audio. */
if (this.mEngineOptions.getAudioOptions().needsSound()) {
this.mSoundManager = new SoundManager(this.mEngineOptions.getAudioOptions().getSoundOptions().getMaxSimultaneousStreams());
} else {
this.mSoundManager = null;
}
if (this.mEngineOptions.getAudioOptions().needsMusic()) {
this.mMusicManager = new MusicManager();
} else {
this.mMusicManager = null;
}
/* Start the UpdateThread. */
if (this.mEngineOptions.hasUpdateThread()) {
this.mUpdateThread = this.mEngineOptions.getUpdateThread();
} else {
this.mUpdateThread = new UpdateThread();
}
this.mUpdateThread.setEngine(this);
}
示例9
public EngineOptions getEngineOptions() {
return this.mEngineOptions;
}
示例10
public SingleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
super(pEngineOptions);
this.mSecondCamera = pSecondCamera;
}
示例11
public DoubleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
super(pEngineOptions);
this.mSecondCamera = pSecondCamera;
}
示例12
@Override
public Engine onCreateEngine(final EngineOptions pEngineOptions) {
return new Engine(pEngineOptions);
}
示例13
@Override
public final EngineOptions onCreateEngineOptions() {
return null;
}
示例14
@Override
public final Engine onCreateEngine(final EngineOptions pEngineOptions) {
return this.onLoadEngine();
}
示例15
public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
super(pEngineOptions);
this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
示例16
public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
super(pEngineOptions);
this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
示例17
public Engine(final EngineOptions pEngineOptions) {
/* Initialize Factory and Manager classes. */
BitmapTextureAtlasTextureRegionFactory.reset();
SoundFactory.onCreate();
MusicFactory.onCreate();
FontFactory.onCreate();
this.mVertexBufferObjectManager.onCreate();
this.mTextureManager.onCreate();
this.mFontManager.onCreate();
this.mShaderProgramManager.onCreate();
/* Apply EngineOptions. */
this.mEngineOptions = pEngineOptions;
if(this.mEngineOptions.hasEngineLock()) {
this.mEngineLock = pEngineOptions.getEngineLock();
} else {
this.mEngineLock = new EngineLock(false);
}
this.mCamera = pEngineOptions.getCamera();
/* Touch. */
if(this.mEngineOptions.getTouchOptions().needsMultiTouch()) {
this.setTouchController(new MultiTouchController());
} else {
this.setTouchController(new SingleTouchController());
}
/* Audio. */
if(this.mEngineOptions.getAudioOptions().needsSound()) {
this.mSoundManager = new SoundManager(this.mEngineOptions.getAudioOptions().getSoundOptions().getMaxSimultaneousStreams());
} else {
this.mSoundManager = null;
}
if(this.mEngineOptions.getAudioOptions().needsMusic()) {
this.mMusicManager = new MusicManager();
} else {
this.mMusicManager = null;
}
/* Start the UpdateThread. */
if(this.mEngineOptions.hasUpdateThread()) {
this.mUpdateThread = this.mEngineOptions.getUpdateThread();
} else {
this.mUpdateThread = new UpdateThread();
}
this.mUpdateThread.setEngine(this);
}
示例18
public EngineOptions getEngineOptions() {
return this.mEngineOptions;
}
示例19
public SingleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
super(pEngineOptions);
this.mSecondCamera = pSecondCamera;
}
示例20
public DoubleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
super(pEngineOptions);
this.mSecondCamera = pSecondCamera;
}
示例21
@Override
public Engine onCreateEngine(final EngineOptions pEngineOptions) {
return new Engine(pEngineOptions);
}
示例22
@Override
public final EngineOptions onCreateEngineOptions() {
return null;
}
示例23
@Override
public final Engine onCreateEngine(final EngineOptions pEngineOptions) {
return this.onLoadEngine();
}
示例24
public EngineOptions onCreateEngineOptions();
示例25
public Engine onCreateEngine(final EngineOptions pEngineOptions);
示例26
public EngineOptions onCreateEngineOptions();
示例27
public Engine onCreateEngine(final EngineOptions pEngineOptions);