Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Label#setVisible()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Label#setVisible() . 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: SelectBoxWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public Actor getSubWidget() {
    selectBox = new SelectBox<>(TalosMain.Instance().UIStage().getSkin(), "propertyValue");
    noValueLabel = new Label("", TalosMain.Instance().UIStage().getSkin());
    noValueLabel.setAlignment(Align.right);
    stack = new Stack();
    stack.add(noValueLabel);
    stack.add(selectBox);

    noValueLabel.setVisible(false);

    listener = new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            String newValue = selectBox.getSelected();
            valueChanged(newValue);
        }
    };
    selectBox.addListener(listener);

    return stack;
}
 
Example 2
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 3
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 4
Source File: Hud.java    From Bomberman_libGdx with MIT License 4 votes vote down vote up
public Hud(SpriteBatch batch, float width, float height) {
    this.batch = batch;

    AssetManager assetManager = GameManager.getInstance().getAssetManager();
    textureAtlas = assetManager.get("img/actors.pack", TextureAtlas.class);
    bombSprite = new Sprite(new TextureRegion(textureAtlas.findRegion("Bomb"), 0, 0, 16, 16));
    bombSprite.setBounds(15.0f, 11.5f, 1, 1);

    Pixmap pixmap = new Pixmap(5, 15, Pixmap.Format.RGBA8888);
    pixmap.setColor(240.0f / 255.0f, 128 / 255.0f, 0, 1.0f);
    pixmap.fill();

    bgTexture = new Texture(pixmap);

    pixmap.setColor(1, 1, 1, 1);
    pixmap.fill();
    bombTimerTexture = new Texture(pixmap);
    pixmap.dispose();

    bombTimerSprite = new Sprite(bombTimerTexture);
    bombTimerSprite.setBounds(16f, 12.5f, 3.0f, 0.2f);

    TextureRegion itemTextureRegion = textureAtlas.findRegion("Items");
    powerSprite = new Sprite(new TextureRegion(itemTextureRegion, 16 * 1, 0, 16, 16));
    powerSprite.setBounds(leftAlignment, 9.0f, 1, 1);

    speedSprite = new Sprite(new TextureRegion(itemTextureRegion, 16 * 2, 0, 16, 16));
    speedSprite.setBounds(leftAlignment, 8.0f, 1, 1);

    kickSprite = new Sprite(new TextureRegion(itemTextureRegion, 16 * 3, 0, 16, 16));
    kickSprite.setBounds(leftAlignment, 7.0f, 1, 1);

    remoteSprite = new Sprite(new TextureRegion(itemTextureRegion, 16 * 4, 0, 16, 16));
    remoteSprite.setBounds(leftAlignment, 6.0f, 1, 1);

    Array<TextureRegion> keyFrames = new Array<TextureRegion>();
    for (int i = 0; i < 5; i++) {
        keyFrames.add(new TextureRegion(textureAtlas.findRegion("Bomberman_big"), 32 * i, 0, 32, 48));
    }
    bigBombermanAnimation = new Animation(0.2f, keyFrames, Animation.PlayMode.LOOP_PINGPONG);
    bigBombermanSprite = new Sprite(bigBombermanAnimation.getKeyFrame(0));
    bigBombermanSprite.setBounds(17.5f, 0.5f, 2f, 3f);
    stateTime = 0;

    FitViewport viewport = new FitViewport(width * SCALE, height * SCALE);
    stage = new Stage(viewport, batch);
    font = new BitmapFont(Gdx.files.internal("fonts/foo.fnt"));
    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
    fpsLabel = new Label("FPS:", labelStyle);
    fpsLabel.setFontScale(0.3f);
    fpsLabel.setPosition(16 * SCALE, -0.8f * SCALE);
    fpsLabel.setVisible(showFPS);
    
    levelLabel = new Label("Level", labelStyle);
    levelLabel.setPosition(15.5f * SCALE, 3 * SCALE);
    levelLabel.setFontScale(0.4f);

    playerLivesLabel = new Label("" + GameManager.playerLives, labelStyle);
    playerLivesLabel.setFontScale(0.5f);
    playerLivesLabel.setPosition(16.8f * SCALE, 12.8f * SCALE);

    Image bombermanImage = new Image(new TextureRegion(textureAtlas.findRegion("Items"), 16 * 5, 0, 16, 16));
    bombermanImage.setPosition(leftAlignment * SCALE, 13.5f * SCALE);

    xLabel = new Label("X", labelStyle);
    xLabel.setFontScale(0.4f);
    xLabel.setPosition(16.8f * SCALE, 6.3f * SCALE);

    zLabel = new Label("Z", labelStyle);
    zLabel.setFontScale(0.4f);
    zLabel.setPosition(16.8f * SCALE, 5.3f * SCALE);

    stage.addActor(fpsLabel);
    stage.addActor(levelLabel);
    stage.addActor(playerLivesLabel);
    stage.addActor(bombermanImage);
    stage.addActor(xLabel);
    stage.addActor(zLabel);
    
    stringBuilder = new StringBuilder();
    
}