Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Label#LabelStyle

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Label#LabelStyle . 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: GameOverScreen.java    From Bomberman_libGdx with MIT License 6 votes vote down vote up
@Override
public void show() {
    viewport = new FitViewport(640, 480);
    stage = new Stage(viewport, batch);

    font = new BitmapFont(Gdx.files.internal("fonts/foo.fnt"));

    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
    Label gameOverLabel = new Label("Game Over", labelStyle);
    gameOverLabel.setPosition((640 - gameOverLabel.getWidth()) / 2, 226f);

    GameManager.getInstance().playMusic("GameOver.ogg", false);

    stage.addActor(gameOverLabel);

    stage.addAction(Actions.sequence(
            Actions.delay(1f),
            Actions.fadeOut(2f),
            Actions.run(new Runnable() {
                @Override
                public void run() {
                    game.setScreen(new MainMenuScreen(game));
                }
            })));

}
 
Example 2
Source File: ShopCard.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
ShopCard(final Klooni game, final GameLayout layout,
         final String itemName, final Color backgroundColor) {
    this.game = game;
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    priceLabel = new Label("", labelStyle);
    nameLabel = new Label(itemName, labelStyle);

    Color labelColor = Theme.shouldUseWhite(backgroundColor) ? Color.WHITE : Color.BLACK;
    priceLabel.setColor(labelColor);
    nameLabel.setColor(labelColor);

    priceBounds = new Rectangle();
    nameBounds = new Rectangle();

    layout.update(this);
}
 
Example 3
Source File: Band.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
public Band(final Klooni game, final GameLayout layout, final BaseScorer scorer) {
    this.scorer = scorer;
    bandTexture = Theme.getBlankTexture();

    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font");

    scoreLabel = new Label("", labelStyle);
    scoreLabel.setAlignment(Align.center);
    infoLabel = new Label("pause menu", labelStyle);
    infoLabel.setAlignment(Align.center);

    scoreBounds = new Rectangle();
    infoBounds = new Rectangle();
    layout.update(this);
}
 
Example 4
Source File: ItemTooltip.java    From Unlucky with MIT License 6 votes vote down vote up
public ItemTooltip(Skin skin) {
    super("", skin);
    desc = new Label("", skin);
    desc.setFontScale(0.5f);
    this.getTitleLabel().setFontScale(0.5f);

    common = new Label.LabelStyle(skin.getFont("default-font"), new Color(1, 1, 1, 1));
    rare = new Label.LabelStyle(skin.getFont("default-font"), new Color(0, 200 / 255.f, 0, 1));
    epic = new Label.LabelStyle(skin.getFont("default-font"), new Color(0, 180 / 255.f, 1, 1));
    legendary = new Label.LabelStyle(skin.getFont("default-font"), new Color(164 / 255.f, 80 / 255.f, 1, 1));

    left();
    // fix padding because of scaling
    this.padTop(12);
    this.padLeft(2);
    this.padBottom(4);
    add(desc);
    pack();
    this.setTouchable(Touchable.disabled);
    this.setVisible(false);
    this.setMovable(false);
    this.setOrigin(Align.bottomLeft);
}
 
Example 5
Source File: Entry.java    From ingress-apk-mod with Apache License 2.0 6 votes vote down vote up
public static void PortalInfoDialog_onStatsTableCreated(PortalInfoDialog dialog, Table t) {
    Mod.portalInfoDialog = dialog;

    Label.LabelStyle style = Mod.skin.get("portal-stats", Label.LabelStyle.class);

    List<Cell> cells = new ArrayList<Cell>(t.getCells());
    t.clear();
    t.add((Actor) cells.get(0).getWidget()).left();
    t.add((Actor) cells.get(1).getWidget()).left().expandX();
    t.row();
    t.add((Actor) cells.get(3).getWidget()).left();
    t.add((Actor) cells.get(4).getWidget()).left().expandX();
    t.row();
    t.add(new Label("Keys:", style)).left();
    t.add(new Label(String.valueOf(InventoryUtils.getNumberOfPortalKeys(dialog.portalComponent)), style)).left().expandX();
    t.row();
    t.add(new Label("Dist.:", style)).left();
    t.add(portalInfoDistLabel = new Label("", style)).left().expandX();
}
 
Example 6
Source File: StringSpin.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public StringSpin(int length, int letterWidth, String initialText) {
    ThesaurusData data = Config.thesaurus.getData("alphabet");
    labels = new Array<Label>(length);
    letters = String.valueOf(shuffleArray((data.en + " " + data.ru).toCharArray())).toUpperCase();
    Array<String> arr = new Array<String>(letters.length());
    arr.addAll(letters.split(""));

    String newLined = arr.toString("\n");
    String doubled = newLined + "\n" + newLined;
    Label.LabelStyle style = Config.skin.get("default", Label.LabelStyle.class);

    lineHeight = style.font.getLineHeight();

    for (int i = 0; i < length; i++) {
        addColumn(i, letterWidth, doubled);
    }
    setSize(letterWidth * length, lineHeight);
    setTextImmediately(initialText);
}
 
Example 7
Source File: FlopsyScreen.java    From flopsydroid with Apache License 2.0 6 votes vote down vote up
public FlopsyScreen(FlopsyDroidGame game, OnGlobalListener listener) {
    mStage = new Stage();

    mGlobalListener = listener;

    game.getAssetManager().load("flopsy.sprites", TextureAtlas.class);
    game.getAssetManager().finishLoading();
    mTextureAtlas = game.getAssetManager().get("flopsy.sprites", TextureAtlas.class);

    mLabelStyle = new Label.LabelStyle();
    mLabelStyle.font = new BitmapFont(Gdx.files.internal("flappyfont.fnt"),
            Gdx.files.internal("flappyfont.png"), false);

    mStage.addListener(new EventListener() {
        @Override
        public boolean handle(Event event) {

            if(event.getTarget().equals(mAndy)) {
                mGround.onDroidCollision();
                return true;
            }

            return false;
        }
    });
}
 
Example 8
Source File: TimeScorer.java    From Klooni1010 with GNU General Public License v3.0 5 votes vote down vote up
public TimeScorer(final Klooni game, GameLayout layout) {
    super(game, layout, Klooni.getMaxTimeScore());
    highScore = Klooni.getMaxTimeScore();

    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font");
    timeLeftLabel = new Label("", labelStyle);
    timeLeftLabel.setAlignment(Align.center);
    layout.updateTimeLeftLabel(timeLeftLabel);

    startTime = TimeUtils.nanoTime();
    deadTime = startTime + START_TIME;

    pausedTimeLeft = -1;
}
 
Example 9
Source File: Util.java    From Unlucky with MIT License 5 votes vote down vote up
public static Label.LabelStyle getItemColor(int rarity, ResourceManager rm) {
    switch (rarity) {
        case 0: return new Label.LabelStyle(rm.skin.getFont("default-font"), new Color(1, 1, 1, 1));
        case 1: return new Label.LabelStyle(rm.skin.getFont("default-font"), new Color(0, 200 / 255.f, 0, 1));
        case 2: return new Label.LabelStyle(rm.skin.getFont("default-font"), new Color(0, 180 / 255.f, 1, 1));
        case 3: return new Label.LabelStyle(rm.skin.getFont("default-font"), new Color(164 / 255.f, 80 / 255.f, 1, 1));
    }
    return null;
}
 
Example 10
Source File: SplashMenu.java    From Cubes with MIT License 5 votes vote down vote up
public SplashMenu() {
  logo = new Image(new TextureRegionDrawable(Assets.getTextureRegion("core:logo.png")), Scaling.fillY, Align.center);
  text = new Label("Loading " + Branding.DEBUG, new Label.LabelStyle(Fonts.smallHUD, Color.WHITE));

  stage.addActor(logo);
  stage.addActor(text);
}
 
Example 11
Source File: LevelStartScreen.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public LevelStartScreen(final NinjaRabbitGame game) {
	super(game);
	PlayerStatus playerStatus = game.getPlayerStatus();
	stage = new Stage(new ScreenViewport(), game.getBatch());

	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = game.getAssetsManager().get(Assets.HUD_FONT);

	TextureAtlas hudAtlas = game.getAssetsManager().get(Assets.NINJA_RABBIT_ATLAS);

	Label collectiblesLabel = new Label(String.format(TWO_DIGITS, playerStatus.getCollectibles()), style);
	Label livesLabel = new Label(String.format(LIVES_FORMAT, playerStatus.getLives()), style);
	Label scoreLabel = new Label(String.format(EIGHT_DIGITS, playerStatus.getScore()), style);
	Label timeLabel = new Label(String.format(THREE_DIGITS, playerStatus.getTime()), style);

	Table status = new Table();
	status.add(new Image(hudAtlas.findRegion(SMALL_CARROT_REGION))).padRight(4.0f);
	status.add(collectiblesLabel).bottom();
	status.add(scoreLabel).expandX();
	status.add(new Image(hudAtlas.findRegion(TIME_REGION))).padRight(12.0f);
	status.add(timeLabel).row();
	status.setFillParent(true);
	status.top();
	status.pad(15.0f);
	stage.addActor(status);

	Table levelInfo = new Table();
	levelInfo.add(new Label(LEVEL_LABEL, style)).expandX().right().padRight(18.0f);
	levelInfo.add(new Label(String.format(LEVEL_FORMAT, playerStatus.getWorld(), playerStatus.getLevel()), style)).expandX()
			.left().padTop(18.0f).row();
	Image livesIcon = new Image(hudAtlas.findRegion(LIVES_REGION));
	levelInfo.add(livesIcon).expandX().right().spaceRight(25f);
	levelInfo.add(livesLabel).expandX().left().bottom();
	levelInfo.setFillParent(true);
	stage.addActor(levelInfo);

}
 
Example 12
Source File: ExampleMain.java    From gdx-smart-font with MIT License 5 votes vote down vote up
@Override
public void create() {
	Gdx.app.setLogLevel(Application.LOG_DEBUG);
	SmartFontGenerator fontGen = new SmartFontGenerator();
	FileHandle exoFile = Gdx.files.local("LiberationMono-Regular.ttf");
	BitmapFont fontSmall = fontGen.createFont(exoFile, "exo-small", 24);
	BitmapFont fontMedium = fontGen.createFont(exoFile, "exo-medium", 48);
	BitmapFont fontLarge = fontGen.createFont(exoFile, "exo-large", 64);

	stage = new Stage();

	Label.LabelStyle smallStyle = new Label.LabelStyle();
	smallStyle.font = fontSmall;
	Label.LabelStyle mediumStyle = new Label.LabelStyle();
	mediumStyle.font = fontMedium;
	Label.LabelStyle largeStyle = new Label.LabelStyle();
	largeStyle.font = fontLarge;

	Label small = new Label("Small Font", smallStyle);
	Label medium = new Label("Medium Font", mediumStyle);
	Label large = new Label("Large Font", largeStyle);

	Table table = new Table();
	table.setFillParent(true);
	table.align(Align.center);
	stage.addActor(table);

	table.defaults().size(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 6);

	table.add(small).row();
	table.add(medium).row();
	table.add(large).row();
}
 
Example 13
Source File: Unlucky.java    From Unlucky with MIT License 4 votes vote down vote up
public void create() {
       batch = new SpriteBatch();
       rm = new ResourceManager();
       player = new Player("player", rm);

       save = new Save(player, "save.json");
       save.load(rm);

       // debugging
       fps = new Label("", new Label.LabelStyle(rm.pixel10, Color.RED));
       fps.setFontScale(0.5f);
       fps.setVisible(player.settings.showFps);

       inventoryUI = new InventoryUI(this, player, rm);
       menuScreen = new MenuScreen(this, rm);
       gameScreen = new GameScreen(this, rm);
       worldSelectScreen = new WorldSelectScreen(this, rm);
       levelSelectScreen = new LevelSelectScreen(this, rm);
       inventoryScreen = new InventoryScreen(this, rm);
       shopScreen = new ShopScreen(this, rm);
       smoveScreen = new SpecialMoveScreen(this, rm);
       statisticsScreen = new StatisticsScreen(this, rm);
       victoryScreen = new VictoryScreen(this, rm);
       settingsScreen = new SettingsScreen(this, rm);

       // create parallax background
       menuBackground = new Background[3];

       // ordered by depth
       // sky
       menuBackground[0] = new Background(rm.titleScreenBackground[0],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0, 0));
       menuBackground[0].setVector(0, 0);
       // back clouds
       menuBackground[1] = new Background(rm.titleScreenBackground[2],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0.3f, 0));
       menuBackground[1].setVector(20, 0);
       // front clouds
       menuBackground[2] = new Background(rm.titleScreenBackground[1],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0.3f, 0));
       menuBackground[2].setVector(60, 0);

       // profiler
       GLProfiler.enable();

       this.setScreen(menuScreen);
}
 
Example 14
Source File: DialogScreen.java    From Unlucky with MIT License 4 votes vote down vote up
public DialogScreen(GameScreen gameScreen, TileMap tileMap, Player player, final ResourceManager rm) {
    super(gameScreen, tileMap, player, rm);

    // create main UI
    ui = new Image(rm.dialogBox400x80);
    ui.setSize(200, 40);
    ui.setPosition(0, 0);
    ui.setTouchable(Touchable.disabled);

    stage.addActor(ui);

    // create Labels
    BitmapFont bitmapFont = rm.pixel10;
    Label.LabelStyle font = new Label.LabelStyle(bitmapFont, new Color(0, 0, 0, 255));

    textLabel = new Label("", font);
    textLabel.setWrap(true);
    textLabel.setTouchable(Touchable.disabled);
    textLabel.setFontScale(1.7f / 2);
    textLabel.setPosition(8, 6);
    textLabel.setSize(350 / 2, 52 / 2);
    textLabel.setAlignment(Align.topLeft);
    stage.addActor(textLabel);

    clickLabel = new Label("", font);
    clickLabel.setSize(200, 120);
    clickLabel.setPosition(0, 0);

    final Player p = player;
    clickLabel.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (dialogIndex + 1 == currentDialog.length && endCycle) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                // the text animation has run through every element of the text array
                endDialog();
                handleEvent(nextEvent);
            }
            // after a cycle of text animation ends, clicking the UI goes to the next cycle
            else if (endCycle && dialogIndex < currentDialog.length) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                dialogIndex++;
                reset();
                currentText = currentDialog[dialogIndex];
                anim = currentText.split("");
                beginCycle = true;
            }
            // clicking on the box during a text animation completes it early
            else if (beginCycle && !endCycle) {
                resultingText = currentText;
                textLabel.setText(resultingText);
                beginCycle = false;
                endCycle = true;
            }
        }
    });
    stage.addActor(clickLabel);
}
 
Example 15
Source File: LevelUpScreen.java    From Unlucky with MIT License 4 votes vote down vote up
public LevelUpScreen(GameScreen gameScreen, TileMap tileMap, Player player, ResourceManager rm) {
    super(gameScreen, tileMap, player, rm);

    // create bg
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    style.imageUp = new TextureRegionDrawable(rm.levelupscreen400x240);
    ui = new ImageButton(style);
    ui.setSize(200, 120);
    ui.setPosition(0, 0);
    ui.setTouchable(Touchable.disabled);
    stage.addActor(ui);

    handleClick();

    // create animation
    levelUpAnim = new AnimationManager(rm.levelUp96x96, 4, 0, 1 / 4f);

    // create labels
    BitmapFont font = rm.pixel10;
    Label.LabelStyle titleFont = new Label.LabelStyle(font, new Color(0, 205 / 255.f, 20 / 255.f, 1));
    Label.LabelStyle stdWhite = new Label.LabelStyle(font, new Color(1, 1, 1, 1));
    Label.LabelStyle yellow = new Label.LabelStyle(font, new Color(1, 212 / 255.f, 0, 1));
    Label.LabelStyle blue = new Label.LabelStyle(font, new Color(0, 190 / 255.f, 1, 1));

    title = new Label("LEVEL UP!", titleFont);
    title.setSize(200, 20);
    title.setPosition(0, 95);
    title.setFontScale(2.5f);
    title.setAlignment(Align.center);
    title.setTouchable(Touchable.disabled);
    stage.addActor(title);

    levelDesc = new Label("You reached level 1", stdWhite);
    levelDesc.setSize(200, 20);
    levelDesc.setPosition(0, 80);
    levelDesc.setAlignment(Align.center);
    levelDesc.setTouchable(Touchable.disabled);
    stage.addActor(levelDesc);

    statsDescs = new Label[statNames.length];
    stats = new Label[statNames.length];
    increases = new Label[statNames.length];

    for (int i = 0; i < statNames.length; i++) {
        statsDescs[i] = new Label(statNames[i], stdWhite);
        statsDescs[i].setSize(10, 10);
        statsDescs[i].setFontScale(1.3f / 2);
        statsDescs[i].setPosition(100, 17 + (i * 12));
        statsDescs[i].setAlignment(Align.left);
        statsDescs[i].setTouchable(Touchable.disabled);
        stage.addActor(statsDescs[i]);

        stats[i] = new Label("1330", blue);
        stats[i].setSize(10, 10);
        stats[i].setFontScale(1.3f / 2);
        stats[i].setPosition(140, 17 + (i * 12));
        stats[i].setAlignment(Align.left);
        stats[i].setTouchable(Touchable.disabled);
        stage.addActor(stats[i]);

        increases[i] = new Label("+20", yellow);
        increases[i].setSize(10, 10);
        increases[i].setFontScale(1.3f / 2);
        increases[i].setPosition(170, 17 + (i * 12));
        increases[i].setAlignment(Align.left);
        increases[i].setTouchable(Touchable.disabled);
        stage.addActor(increases[i]);
    }

    clickToContinue = new Label("Click to continue", stdWhite);
    clickToContinue.setSize(200, 10);
    clickToContinue.setFontScale(0.5f);
    clickToContinue.setPosition(0, 2);
    clickToContinue.setAlignment(Align.center);
    clickToContinue.setTouchable(Touchable.disabled);
    stage.addActor(clickToContinue);
}
 
Example 16
Source File: BattleEventHandler.java    From Unlucky with MIT License 4 votes vote down vote up
public BattleEventHandler(GameScreen gameScreen, TileMap tileMap, Player player, Battle battle,
                          BattleUIHandler uiHandler, Stage stage, final ResourceManager rm) {
    super(gameScreen, tileMap, player, battle, uiHandler, rm);

    this.stage = stage;

    // create main UI
    ui = new Image(rm.dialogBox400x80);
    ui.setSize(200, 40);
    ui.setPosition(0, 0);
    ui.setTouchable(Touchable.disabled);

    stage.addActor(ui);

    // create Labels
    BitmapFont bitmapFont = rm.pixel10;
    Label.LabelStyle font = new Label.LabelStyle(bitmapFont, new Color(0, 0, 0, 255));

    textLabel = new Label("", font);
    textLabel.setWrap(true);
    textLabel.setTouchable(Touchable.disabled);
    textLabel.setFontScale(1.7f / 2);
    textLabel.setPosition(8, 6);
    textLabel.setSize(175, 26);
    textLabel.setAlignment(Align.topLeft);
    stage.addActor(textLabel);

    clickLabel = new Label("", font);
    clickLabel.setSize(200, 120);
    clickLabel.setPosition(0, 0);

    final Player p = player;
    clickLabel.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (dialogIndex + 1 == currentDialog.length && endCycle) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                // the text animation has run through every element of the text array
                endDialog();
                handleBattleEvent(nextEvent);
            }
            // after a cycle of text animation ends, clicking the UI goes to the next cycle
            else if (endCycle && dialogIndex < currentDialog.length) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                dialogIndex++;
                reset();
                currentText = currentDialog[dialogIndex];
                anim = currentText.split("");
                beginCycle = true;
            }
            // clicking on the box during a text animation completes it early
            else if (beginCycle && !endCycle) {
                resultingText = currentText;
                textLabel.setText(resultingText);
                beginCycle = false;
                endCycle = true;
            }
        }
    });
    stage.addActor(clickLabel);
}
 
Example 17
Source File: Main.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
@Override
public void create() {

  if(this.overrideLogger != null){
    Gdx.app.setApplicationLogger(overrideLogger);
  }

  // Only DesktopLauncher sets this.
  if(gl30 == null) {
    // Gdx.gl30 could also be null though.
    gl30 = Gdx.gl30;
  }

  Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);
  Gdx.graphics.getGL20().glEnable(GL20.GL_DEPTH_TEST);
  Gdx.graphics.getGL20().glDepthFunc(GL20.GL_LESS);

  standardMesh = buildFullScreenQuadMesh();

  if(standaloneRenderJob != null) {
    if (standaloneRenderJob.isSetComputeSource()) {
      updateState(WorkerState.COMPUTE_STANDALONE_PREPARE);
    } else {
      updateState(WorkerState.IMAGE_STANDALONE_PREPARE);
    }
    return;
  }

  PlatformInfoUtil.getPlatformDetails(platformInfoJson);
  PlatformInfoUtil.getGlVersionInfo(platformInfoJson, gl30);

  sanityReferenceImage = createPixelBuffer();
  sanityCheckImage = createPixelBuffer();
  sanityCheckImageTmp = createPixelBuffer();

  GdxStage = new Stage(new ScreenViewport());
  Label.LabelStyle label1Style = new Label.LabelStyle();
  label1Style.font = new BitmapFont();
  label1Style.fontColor = Color.WHITE;

  DisplayContent = new StringBuilder();
  DisplayLabel = new Label(DisplayContent.toString(), label1Style);
  DisplayLabel.setPosition(WIDTH + DISPLAY_TXT_MARGIN, 0);
  DisplayLabel
      .setSize(Gdx.graphics.getWidth() - WIDTH - DISPLAY_TXT_MARGIN - 10, Gdx.graphics.getHeight() - 10);
  DisplayLabel.setAlignment(Align.topLeft);
  DisplayContent = new StringBuilder();
  GdxStage.addActor(DisplayLabel);
}
 
Example 18
Source File: ShareChallenge.java    From Klooni1010 with GNU General Public License v3.0 4 votes vote down vote up
public boolean saveChallengeImage(final int score, final boolean timeMode) {
    final File saveAt = getShareImageFilePath();
    if (!saveAt.getParentFile().isDirectory())
        if (!saveAt.mkdirs())
            return false;

    final FileHandle output = new FileHandle(saveAt);

    final Texture shareBase = new Texture(Gdx.files.internal("share.png"));
    final int width = shareBase.getWidth();
    final int height = shareBase.getHeight();

    final FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, width, height, false);
    frameBuffer.begin();

    // Render the base share texture
    final SpriteBatch batch = new SpriteBatch();
    final Matrix4 matrix = new Matrix4();
    matrix.setToOrtho2D(0, 0, width, height);
    batch.setProjectionMatrix(matrix);

    Gdx.gl.glClearColor(Color.GOLD.r, Color.GOLD.g, Color.GOLD.b, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    batch.draw(shareBase, 0, 0);

    // Render the achieved score
    final Label.LabelStyle style = new Label.LabelStyle();
    style.font = new BitmapFont(Gdx.files.internal("font/x1.0/geosans-light64.fnt"));
    Label label = new Label("just scored " + score + " on", style);
    label.setColor(Color.BLACK);
    label.setPosition(40, 500);
    label.draw(batch, 1);

    label.setText("try to beat me if you can");
    label.setPosition(40, 40);
    label.draw(batch, 1);

    if (timeMode) {
        Texture timeModeTexture = new Texture("ui/x1.5/stopwatch.png");
        batch.setColor(Color.BLACK);
        batch.draw(timeModeTexture, 200, 340);
    }

    batch.end();

    // Get the framebuffer pixels and write them to a local file
    final byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, width, height, true);

    final Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);

    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
    PixmapIO.writePNG(output, pixmap);

    // Dispose everything
    pixmap.dispose();
    shareBase.dispose();
    batch.dispose();
    frameBuffer.end();

    return true;
}
 
Example 19
Source File: PlayScreen.java    From Pacman_libGdx with MIT License 4 votes vote down vote up
@Override
public void show() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(WIDTH, HEIGHT, camera);
    camera.translate(WIDTH / 2, HEIGHT / 2);
    camera.update();

    batch = new SpriteBatch();

    playerSystem = new PlayerSystem();
    ghostSystem = new GhostSystem();
    movementSystem = new MovementSystem();
    pillSystem = new PillSystem();
    animationSystem = new AnimationSystem();
    renderSystem = new RenderSystem(batch);
    stateSystem = new StateSystem();

    engine = new Engine();
    engine.addSystem(playerSystem);
    engine.addSystem(ghostSystem);
    engine.addSystem(pillSystem);
    engine.addSystem(movementSystem);
    engine.addSystem(stateSystem);
    engine.addSystem(animationSystem);
    engine.addSystem(renderSystem);

    // box2d
    world = new World(Vector2.Zero, true);
    world.setContactListener(new WorldContactListener());
    box2DDebugRenderer = new Box2DDebugRenderer();
    showBox2DDebuggerRenderer = false;

    // box2d light
    rayHandler = new RayHandler(world);
    rayHandler.setAmbientLight(ambientLight);

    // load map
    tiledMap = new TmxMapLoader().load("map/map.tmx");
    tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap, 1 / 16f, batch);

    new WorldBuilder(tiledMap, engine, world, rayHandler).buildAll();

    stageViewport = new FitViewport(WIDTH * 20, HEIGHT * 20);
    stage = new Stage(stageViewport, batch);

    font = new BitmapFont(Gdx.files.internal("fonts/army_stencil.fnt"));
    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);

    Label scoreTextLabel = new Label("SCORE", labelStyle);
    scoreTextLabel.setPosition(WIDTH * 1, HEIGHT * 19);
    stage.addActor(scoreTextLabel);

    Label hightScoreTextLabel = new Label("High Score", labelStyle);
    hightScoreTextLabel.setPosition(WIDTH * 14, HEIGHT * 19);
    stage.addActor(hightScoreTextLabel);

    scoreLabel = new Label("0", labelStyle);
    scoreLabel.setPosition(WIDTH * 1.5f, HEIGHT * 18.2f);
    stage.addActor(scoreLabel);

    highScoreLabel = new Label("0", labelStyle);
    highScoreLabel.setPosition(WIDTH * 16.5f, HEIGHT * 18.2f);
    stage.addActor(highScoreLabel);

    gameOverLabel = new Label("              - Game Over -\n Press Enter to continue", labelStyle);
    gameOverLabel.setPosition(WIDTH * 4.3f, HEIGHT * 9f);
    gameOverLabel.setVisible(false);
    stage.addActor(gameOverLabel);

    TextureAtlas textureAtlas = GameManager.instance.assetManager.get("images/actors.pack", TextureAtlas.class);
    pacmanSprite = new Sprite(new TextureRegion(textureAtlas.findRegion("Pacman"), 16, 0, 16, 16));
    pacmanSprite.setBounds(8f, 21.5f, 16 / GameManager.PPM, 16 / GameManager.PPM);

    stringBuilder = new StringBuilder();

    changeScreen = false;
}
 
Example 20
Source File: BonusParticle.java    From Klooni1010 with GNU General Public License v3.0 4 votes vote down vote up
BonusParticle(final Vector2 pos, final int score, final Label.LabelStyle style) {
    label = new Label("+" + score, style);
    label.setBounds(pos.x, pos.y, 0, 0);
}