Ejemplo n.º 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) {}
        });
  }
Ejemplo n.º 2
0
  @Override
  public void start() {
    super.start();
    if (this.type == FinalStage.TYPE_GAME_OVER) {
      StageScreen.getInstance().getTracker().trackScreen("gameOverScreen");
    } else {
      StageScreen.getInstance().getTracker().trackScreen("gameWinScreen");
    }
    this.music = Manager.getInstance().get(musicFile, Music.class);
    this.music.setVolume(Settings.getInstance().getMusicVolume());
    this.music.play();

    TextureAtlas atlas = Manager.getInstance().get("img/menu.pack", TextureAtlas.class);
    LabelStyle headerStyle = new LabelStyle();
    headerStyle.font = Config.getInstance().headerFont;
    headerStyle.fontColor = Config.getInstance().textColor;

    String labelText = (type == FinalStage.TYPE_GAME_OVER) ? "game.over" : "game.win";
    Label text = new Label(Translator.getInstance().translate(labelText), headerStyle);
    text.setBounds(
        50, 150, Config.getInstance().gameWidth - 100, Config.getInstance().gameHeight - 150);
    text.setAlignment(Align.center);
    text.setWrap(true);
    text.getColor().a = 0;
    text.addAction(fadeIn(2f));
    this.addActor(text);

    AtlasRegion btnBg = atlas.findRegion("btn-bg");
    AtlasRegion btnBgTouched = atlas.findRegion("btn-bg-touched");
    Color btnColor = new Color(1, 1, 1, 1);
    Color btnColorTouched = new Color(0.5f, 0.5f, 0.5f, 1);

    TextButton newGame =
        new TextButton(
            btnBg,
            btnBgTouched,
            Translator.getInstance().translate("btn.new.game"),
            Config.getInstance().bigFont,
            btnColor,
            btnColorTouched);
    newGame.setHeight(btnHeight);
    newGame.setPosition(50, 50);
    newGame.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            StageScreen.getInstance().setStage(new SlideStage(SlideStage.TYPE_INTRO));
          }
        });
    this.addActor(newGame);

    TextButton exit =
        new TextButton(
            btnBg,
            btnBgTouched,
            Translator.getInstance().translate("btn.exit"),
            Config.getInstance().bigFont,
            btnColor,
            btnColorTouched);
    exit.setHeight(btnHeight);
    exit.setPosition(Config.getInstance().gameWidth - exit.getWidth() - 50, 50);
    exit.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            StageScreen.getInstance().setStage(new MenuStage());
          }
        });
    this.addActor(exit);
  }
Ejemplo n.º 3
0
  @Override
  public void show() {
    imgNinja = new Texture(Gdx.files.internal("Ninja-Shadow.png"));
    imgNinja.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("lastninja.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.genMipMaps = true;
    parameter.minFilter = Texture.TextureFilter.Linear.MipMapLinearNearest;
    parameter.magFilter = Texture.TextureFilter.Linear;
    parameter.size = 26;
    final BitmapFont font = generator.generateFont(parameter);

    startLabel = new Label("Start Game", new Label.LabelStyle(font, Color.BLACK));
    startLabel.setPosition(500, 300);
    startLabel.setTouchable(Touchable.enabled);
    startLabel.setBounds(500, 300, startLabel.getWidth(), startLabel.getHeight());
    startLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new PlayScreen(game));
            dispose();
          }
        });

    instructionLabel = new Label("Instructions", new Label.LabelStyle(font, Color.BLACK));
    instructionLabel.setPosition(500, 250);
    instructionLabel.setTouchable(Touchable.enabled);
    instructionLabel.setBounds(500, 250, instructionLabel.getWidth(), instructionLabel.getHeight());
    instructionLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new InstructionScreen(game));
            dispose();
          }
        });

    aboutLabel = new Label("About", new Label.LabelStyle(font, Color.BLACK));
    aboutLabel.setPosition(500, 200);
    aboutLabel.setTouchable(Touchable.enabled);
    aboutLabel.setBounds(500, 200, aboutLabel.getWidth(), aboutLabel.getHeight());
    aboutLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new AboutScreen(game));
            dispose();
          }
        });
    quitLabel = new Label("Quit", new Label.LabelStyle(font, Color.BLACK));
    quitLabel.setPosition(500, 150);
    quitLabel.setTouchable(Touchable.enabled);
    quitLabel.setBounds(500, 150, quitLabel.getWidth(), quitLabel.getHeight());
    quitLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    stage.addActor(startLabel);
    stage.addActor(instructionLabel);
    stage.addActor(aboutLabel);
    stage.addActor(quitLabel);
  }