예제 #1
0
  public SettingsScreen(AbstractScreen parentScreen) {
    super(parentScreen);
    initFitViewport();

    //        final AbstractAuthService authService =
    // mAdapter.getPlatformServices().getAuthService();

    mBgStage.loadImage(this, "Bg/menu/settings-bg.jpg");

    BackButton.create(this, MainMenuScreen.class);

    mSettings = new LocalSettings();

    final CheckBox cbSounds = new CheckBox("", RM.getCheckBoxStyle());
    cbSounds.setBounds(20, 500, SES.BUTTON_HEIGHT, SES.BUTTON_HEIGHT);
    cbSounds.setChecked(mSettings.getSoundEnabled());

    mStage.addActor(cbSounds);
    cbSounds.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            mSettings.setSoundEnabled(cbSounds.isChecked());
            mSettings.flush();
          }
        });

    Label lblSounds = new Label("Sound effects", RM.getLabelStyle());
    lblSounds.setBounds(120, 500, 200, SES.BUTTON_HEIGHT);
    mStage.addActor(lblSounds);

    final CheckBox cbMusic = new CheckBox("", RM.getCheckBoxStyle());
    cbMusic.setBounds(20, 400, SES.BUTTON_HEIGHT, SES.BUTTON_HEIGHT);
    cbMusic.setChecked(mSettings.getMusicEnabled());
    mStage.addActor(cbMusic);
    cbMusic.addListener(
        new ClickListener() {

          public void clicked(InputEvent event, float x, float y) {
            mSettings.setMusicEnabled(cbMusic.isChecked());
            mSettings.flush();
          }
        });

    Label lblMusic = new Label("Music", RM.getLabelStyle());
    lblMusic.setBounds(120, 400, 200, SES.BUTTON_HEIGHT);
    mStage.addActor(lblMusic);

    TextButton btnGooglePlayLink = new TextButton("GooglePlay", RM.getTextButtonStyle());
    btnGooglePlayLink.setBounds(SES.buttonRight(), 20, SES.BUTTON_WIDTH, SES.BUTTON_HEIGHT);
    mStage.addActor(btnGooglePlayLink);
    btnGooglePlayLink.addListener(
        new ClickListener() {

          public void clicked(InputEvent event, float x, float y) {}
        });
  }
  private void createSoundFXToggleButton(AssetManager assetManager) {

    Texture soundFXButtonActiveTexture =
        assetManager.get("soundfxbutton_active.png", Texture.class);
    Texture soundFXButtonInactiveTexture =
        assetManager.get("soundfxbutton_inactive.png", Texture.class);

    // Run
    // "texture through 2 other thingys to turn it into a "TextureRegiionDrawable,
    // which is what the "Button" constructor needs.
    TextureRegion soundFXActiveButtonTR = new TextureRegion(soundFXButtonActiveTexture);
    TextureRegion soundFXInactiveButtonTR = new TextureRegion(soundFXButtonInactiveTexture);

    TextureRegionDrawable soundFXButtonActiveTRD = new TextureRegionDrawable(soundFXActiveButtonTR);
    TextureRegionDrawable soundFXButtonInactiveTRD =
        new TextureRegionDrawable(soundFXInactiveButtonTR);

    // Create the start button
    CheckBoxStyle s = new CheckBoxStyle();
    s.font = new BitmapFont();
    s.checkboxOn = soundFXButtonActiveTRD;
    s.checkboxOn.setMinHeight(buttonRowHeight);
    s.checkboxOn.setMinWidth(buttonRowHeight);
    s.checkboxOff = soundFXButtonInactiveTRD;
    s.checkboxOff.setMinHeight(buttonRowHeight);
    s.checkboxOff.setMinWidth(buttonRowHeight);
    soundFXButton = new CheckBox("", s);
    soundFXButton.setChecked(true);

    // Define how big it is.
    soundFXButton.setBounds(0f, 0f, buttonRowHeight, buttonRowHeight);

    // Move it to where it should go on the screen.
    soundFXButton.setPosition(
        screenDimensions.x - (buttonColumnWidth + verticalBorderAmount * 4),
        screenDimensions.y - (horizontalBorderAmount + buttonRowHeight * 4 + lineSpacing * 3));

    // Tell it to notify this class (StartScreen) when clicked.
    soundFXButton.addListener(this);

    // Add it to the stage so it will "act" and "draw" when the stage does.
    stage.addActor(soundFXButton);
  }