org.andengine.engine.options.EngineOptions Java Examples

The following examples show how to use org.andengine.engine.options.EngineOptions. 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: AndEngineActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@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 #2
Source File: GameActivity.java    From sopa with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #3
Source File: BaseGameActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
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;
	}
}
 
Example #4
Source File: FlipGameActivity.java    From tilt-game-android with MIT License 5 votes vote down vote up
@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 #5
Source File: BaseGameActivity.java    From tilt-game-android with MIT License 5 votes vote down vote up
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;
	}
}
 
Example #6
Source File: Engine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example #7
Source File: FixedStepEngine.java    From tilt-game-android with MIT License 4 votes vote down vote up
public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
	super(pEngineOptions);

	this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
 
Example #8
Source File: LegacyBaseGameActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public final Engine onCreateEngine(final EngineOptions pEngineOptions) {
	return this.onLoadEngine();
}
 
Example #9
Source File: LegacyBaseGameActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public final EngineOptions onCreateEngineOptions() {
	return null;
}
 
Example #10
Source File: LimitedFPSEngine.java    From tilt-game-android with MIT License 4 votes vote down vote up
public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
	super(pEngineOptions);

	this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
 
Example #11
Source File: BaseGameActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public Engine onCreateEngine(final EngineOptions pEngineOptions) {
	return new Engine(pEngineOptions);
}
 
Example #12
Source File: DoubleSceneSplitScreenEngine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public DoubleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
	super(pEngineOptions);
	this.mSecondCamera = pSecondCamera;
}
 
Example #13
Source File: SingleSceneSplitScreenEngine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public SingleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
	super(pEngineOptions);
	this.mSecondCamera = pSecondCamera;
}
 
Example #14
Source File: Engine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public EngineOptions getEngineOptions() {
	return this.mEngineOptions;
}
 
Example #15
Source File: SingleSceneSplitScreenEngine.java    From tilt-game-android with MIT License 4 votes vote down vote up
public SingleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
	super(pEngineOptions);
	this.mSecondCamera = pSecondCamera;
}
 
Example #16
Source File: LimitedFPSEngine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
	super(pEngineOptions);
	this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
 
Example #17
Source File: FixedStepEngine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
	super(pEngineOptions);
	this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
 
Example #18
Source File: Engine.java    From tilt-game-android with MIT License 4 votes vote down vote up
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);
}
 
Example #19
Source File: LegacyBaseGameActivity.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public final Engine onCreateEngine(final EngineOptions pEngineOptions) {
	return this.onLoadEngine();
}
 
Example #20
Source File: LegacyBaseGameActivity.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public final EngineOptions onCreateEngineOptions() {
	return null;
}
 
Example #21
Source File: Engine.java    From tilt-game-android with MIT License 4 votes vote down vote up
public EngineOptions getEngineOptions() {
	return this.mEngineOptions;
}
 
Example #22
Source File: BaseGameActivity.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public Engine onCreateEngine(final EngineOptions pEngineOptions) {
	return new Engine(pEngineOptions);
}
 
Example #23
Source File: DoubleSceneSplitScreenEngine.java    From tilt-game-android with MIT License 4 votes vote down vote up
public DoubleSceneSplitScreenEngine(final EngineOptions pEngineOptions, final Camera pSecondCamera) {
	super(pEngineOptions);
	this.mSecondCamera = pSecondCamera;
}
 
Example #24
Source File: IGameInterface.java    From 30-android-libraries-in-30-days with Apache License 2.0 votes vote down vote up
public EngineOptions onCreateEngineOptions(); 
Example #25
Source File: IGameInterface.java    From 30-android-libraries-in-30-days with Apache License 2.0 votes vote down vote up
public Engine onCreateEngine(final EngineOptions pEngineOptions); 
Example #26
Source File: IGameInterface.java    From tilt-game-android with MIT License votes vote down vote up
public Engine onCreateEngine(final EngineOptions pEngineOptions); 
Example #27
Source File: IGameInterface.java    From tilt-game-android with MIT License votes vote down vote up
public EngineOptions onCreateEngineOptions();