@Override public void onLoadLayer() { if (this.mHasLoaded) { return; } this.mHasLoaded = true; this.setTouchAreaBindingOnActionDownEnabled(true); this.setTouchAreaBindingOnActionMoveEnabled(true); final Rectangle fadableBGRect = new Rectangle( 0f, 0f, ResourceManager.getInstance().cameraWidth, ResourceManager.getInstance().cameraHeight, ResourceManager.getActivity().getVertexBufferObjectManager()); fadableBGRect.setColor(0f, 0f, 0f, 0.5f); this.attachChild(fadableBGRect); this.attachChild( this.mLayerBG = new Sprite( 0f, (ResourceManager.getInstance().cameraHeight / 2f) + (ResourceManager.gameLevelLayerBGTR.getHeight() / 2f), ResourceManager.gameLevelLayerBGTR, ResourceManager.getActivity().getVertexBufferObjectManager())); this.mLayerBG.setScale(1.5f / ResourceManager.getInstance().cameraScaleFactorY); final GrowButton BackToLevelSelectButton = new GrowButton(128.2f, 75f, ResourceManager.gameLevelLayerButtonLevelSelectTR, false) { @Override public void onClick() { LevelWonLayer.this.mIsGoingToRestartLevel = false; LevelWonLayer.this.mIsGoingToNextLevel = false; LevelWonLayer.this.onHideLayer(); } }; this.mLayerBG.attachChild(BackToLevelSelectButton); this.registerTouchArea(BackToLevelSelectButton); final GrowButton RestartLevelButton = new GrowButton(256f, 75f, ResourceManager.gameLevelLayerButtonRestartLevelTR, false) { @Override public void onClick() { LevelWonLayer.this.mIsGoingToRestartLevel = true; LevelWonLayer.this.mIsGoingToNextLevel = false; LevelWonLayer.this.onHideLayer(); } }; this.mLayerBG.attachChild(RestartLevelButton); this.registerTouchArea(RestartLevelButton); final GrowButton NextLevelButton = new GrowButton(383f, 75f, ResourceManager.gameLevelLayerButtonNextLevelTR, false) { @Override public void onClick() { LevelWonLayer.this.mIsGoingToRestartLevel = false; LevelWonLayer.this.mIsGoingToNextLevel = true; LevelWonLayer.this.onHideLayer(); } }; this.mLayerBG.attachChild(NextLevelButton); this.registerTouchArea(NextLevelButton); this.mLayerBG.attachChild( new Sprite( 365f, 148f, ResourceManager.gameLevelLayerStarsBGTR, ResourceManager.getActivity().getVertexBufferObjectManager())); this.mLayerBG.attachChild( this.mStarsTiledSprite = new TiledSprite( 365f, 148f, ResourceManager.gameLevelLayerStarsTTR, ResourceManager.getActivity().getVertexBufferObjectManager())); this.mMainText = new Text( 0f, 0f, ResourceManager.fontDefaultMagneTank48, "LEVEL *** SUCCESS!", ResourceManager.getActivity().getVertexBufferObjectManager()); this.mMainText.setScale(Math.min(390f / this.mMainText.getWidth(), 1f)); this.mMainText.setPosition(256f, 205f); this.mMainText.setColor(0.31f, 0.35f, 0.31f); this.mLayerBG.attachChild(this.mMainText); this.mScoreText = new Text( 0f, 0f, ResourceManager.fontDefaultMagneTank48, "SCORE: *****", ResourceManager.getActivity().getVertexBufferObjectManager()); this.mScoreText.setAnchorCenterX(0f); this.mScoreText.setScale(Math.min(203f / this.mScoreText.getWidth(), 1f)); this.mScoreText.setPosition(80f, 155f); this.mScoreText.setColor(0.31f, 0.35f, 0.31f); this.mLayerBG.attachChild(this.mScoreText); this.mHighScoreText = new Text( 0f, 0f, ResourceManager.fontDefaultMagneTank48, "HIGHSCORE: *****", ResourceManager.getActivity().getVertexBufferObjectManager()); this.mHighScoreText.setAnchorCenterX(0f); this.mHighScoreText.setScale(Math.min(203f / this.mHighScoreText.getWidth(), 1f)); this.mHighScoreText.setPosition(80f, 128f); this.mHighScoreText.setColor(0.31f, 0.35f, 0.31f); this.mLayerBG.attachChild(this.mHighScoreText); this.setPosition( ResourceManager.getInstance().cameraWidth / 2f, ResourceManager.getInstance().cameraHeight / 2f); }
@Override public void onLoadLayer() { if (this.mHasLoaded) { return; } this.mHasLoaded = true; this.setTouchAreaBindingOnActionDownEnabled(true); this.setTouchAreaBindingOnActionMoveEnabled(true); final Rectangle fadableBGRect = new Rectangle( 0f, 0f, ResourceManager.getInstance().cameraWidth / 2, ResourceManager.getInstance().cameraHeight / 2, ResourceManager.getActivity().getVertexBufferObjectManager()); fadableBGRect.setColor(0f, 0f, 0f, 0.8f); this.attachChild(fadableBGRect); this.attachChild( this.LayerBG = new Sprite( 0f, (ResourceManager.getInstance().cameraHeight / 2f) + (ResourceManager.gameLevelLayerBGTR.getHeight() / 2f), ResourceManager.gameLevelLayerBGTR, ResourceManager.getActivity().getVertexBufferObjectManager())); this.LayerBG.setScale(1.5f / ResourceManager.getInstance().cameraScaleFactorY); this.TitleText = new Text( 0f, 0f, ResourceManager.fontDefaultMagneTank48, "OPTIONS", ResourceManager.getActivity().getVertexBufferObjectManager()); this.TitleText.setScale(Math.min(390f / this.TitleText.getWidth(), 1f)); this.TitleText.setPosition(256f, 225f); this.TitleText.setColor(0.31f, 0.35f, 0.31f); this.LayerBG.attachChild(this.TitleText); this.SoundEnabledText = new GrowToggleTextButton( 256f, 197.2f, "SOUND: ENABLED", "SOUND: DISABLED", ResourceManager.fontDefaultMagneTank48, !SFXManager.isSoundMuted()) { @Override public boolean checkState() { return !SFXManager.isSoundMuted(); } @Override public void onClick() { SFXManager.toggleSoundMuted(); } }; this.SoundEnabledText.setScales( Math.min(390f / this.SoundEnabledText.getWidth(), 0.85f), Math.min(390f / this.SoundEnabledText.getWidth(), 0.85f) * 1.4f); this.SoundEnabledText.setColor(0.212f, 0.275f, 0.212f); this.LayerBG.attachChild(this.SoundEnabledText); this.registerTouchArea(this.SoundEnabledText); this.MusicEnabledText = new GrowToggleTextButton( 256f, 169.4f, "MUSIC: ENABLED", "MUSIC: DISABLED", ResourceManager.fontDefaultMagneTank48, !SFXManager.isMusicMuted()) { @Override public boolean checkState() { return !SFXManager.isMusicMuted(); } @Override public void onClick() { SFXManager.toggleMusicMuted(); } }; this.MusicEnabledText.setScales( Math.min(390f / this.MusicEnabledText.getWidth(), 0.85f), Math.min(390f / this.MusicEnabledText.getWidth(), 0.85f) * 1.2f); this.MusicEnabledText.setColor(0.212f, 0.275f, 0.212f); this.LayerBG.attachChild(this.MusicEnabledText); this.registerTouchArea(this.MusicEnabledText); this.GraphicsQualityText = new GrowToggleTextButton( 256f, 141.6f, "GRAPHICS: HIGH", "GRAPHICS: NORMAL", ResourceManager.fontDefaultMagneTank48, ResourceManager.isUsingHighQualityGraphics()) { @Override public boolean checkState() { return ResourceManager.isUsingHighQualityGraphics(); } @Override public void onClick() { ResourceManager.getInstance().switchQuality(); } }; this.GraphicsQualityText.setScales( Math.min(390f / this.GraphicsQualityText.getWidth(), 0.85f), Math.min(390f / this.GraphicsQualityText.getWidth(), 0.85f) * 1.2f); this.GraphicsQualityText.setColor(0.212f, 0.275f, 0.212f); this.LayerBG.attachChild(this.GraphicsQualityText); this.registerTouchArea(this.GraphicsQualityText); this.ResetText = new GrowToggleTextButton( 256f, 113.8f, "RESET DATA", "", ResourceManager.fontDefaultMagneTank48, true) { @Override public boolean checkState() { return true; } @Override public void onClick() { ResourceManager.getActivity() .runOnUiThread( new Runnable() { @Override public void run() { final AlertDialog.Builder builder = new AlertDialog.Builder(ResourceManager.getActivity()); builder.setTitle("Reset Game Data?"); builder.setIcon(R.drawable.icon); builder .setMessage( "This will reset all scores and stars that you've achieved. Continue?") .setPositiveButton( "Reset Data", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { final int ActivityStartCount = TimelessWarriorsActivity.getIntFromSharedPreferences( TimelessWarriorsActivity .SHARED_PREFS_ACTIVITY_START_COUNT); final int MusicMuted = TimelessWarriorsActivity.getIntFromSharedPreferences( TimelessWarriorsActivity.SHARED_PREFS_MUSIC_MUTED); final boolean Quality = TimelessWarriorsActivity.getBooleanFromSharedPreferences( TimelessWarriorsActivity .SHARED_PREFS_HIGH_QUALITY_GRAPHICS); final int MarketRated = TimelessWarriorsActivity.getIntFromSharedPreferences( TimelessWarriorsActivity.SHARED_PREFS_RATING_SUCCESS); final int SoundMuted = TimelessWarriorsActivity.getIntFromSharedPreferences( TimelessWarriorsActivity.SHARED_PREFS_SOUNDS_MUTED); ResourceManager.getActivity() .getSharedPreferences( TimelessWarriorsActivity.SHARED_PREFS_MAIN, 0) .edit() .clear() .putInt( TimelessWarriorsActivity .SHARED_PREFS_ACTIVITY_START_COUNT, ActivityStartCount) .putInt( TimelessWarriorsActivity.SHARED_PREFS_MUSIC_MUTED, MusicMuted) .putBoolean( TimelessWarriorsActivity .SHARED_PREFS_HIGH_QUALITY_GRAPHICS, Quality) .putInt( TimelessWarriorsActivity.SHARED_PREFS_RATING_SUCCESS, MarketRated) .putInt( TimelessWarriorsActivity.SHARED_PREFS_SOUNDS_MUTED, SoundMuted) .apply(); MainMenu.getInstance().RefreshLevelStars(); } }) .setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) {} }) .setCancelable(false); final AlertDialog alert = builder.create(); alert.show(); } }); } }; this.ResetText.setScales( Math.min(390f / this.ResetText.getWidth(), 0.85f), Math.min(390f / this.ResetText.getWidth(), 0.85f) * 1.2f); this.ResetText.setColor(0.212f, 0.275f, 0.212f); this.LayerBG.attachChild(this.ResetText); this.registerTouchArea(this.ResetText); final GrowButton BackToTitleButton = new GrowButton(0f, 0f, ResourceManager.menuArrow2TR, false) { @Override public void onClick() { OptionsLayer.this.onHideLayer(); } }; BackToTitleButton.setFlippedHorizontal(true); this.LayerBG.attachChild(BackToTitleButton); BackToTitleButton.setPosition(256f, 66f); this.registerTouchArea(BackToTitleButton); this.setPosition( ResourceManager.getInstance().cameraWidth / 2f, ResourceManager.getInstance().cameraHeight / 2f); }