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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Image#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: NodeStage.java    From talos with Apache License 2.0 5 votes vote down vote up
private void initActors() {
    GridRenderer gridRenderer = new GridRenderer(stage);
    stage.addActor(gridRenderer);

    moduleBoardWidget = new ModuleBoardWidget(this);

    stage.addActor(moduleBoardWidget);

    selectionRect = new Image(skin.getDrawable("orange_row"));
    selectionRect.setSize(0, 0);
    selectionRect.setVisible(false);
    stage.addActor(selectionRect);
}
 
Example 2
Source File: PortraitUI.java    From Norii with Apache License 2.0 5 votes vote down vote up
private void createPortraitBorderTexture() {
	Utility.loadTextureAsset(PORTRAIT_BORDER_FILE_PATH);
	final TextureRegion trBorder = new TextureRegion(Utility.getTextureAsset(PORTRAIT_BORDER_FILE_PATH));
	heroPortraitScalableBorder = new TextureRegionDrawable(trBorder);
	heroPortraitBorder = new Image(heroPortraitScalableBorder);
	heroPortraitBorder.setVisible(false);
}
 
Example 3
Source File: MessageTests.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void create () {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

	skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	stage = new Stage();
	stage.setDebugAll(DEBUG_STAGE);
	stageWidth = stage.getWidth();
	stageHeight = stage.getHeight();

	Gdx.input.setInputProcessor(stage);

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stageWidth, stageHeight);
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create test selection window
	List<String> testList = createTestList();
	testSelectionWindow = addTestSelectionWindow("Tests", testList, 0, -1);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(testDescriptionLabel = new Label("", skin)).padLeft(15);
	stage.addActor(statusBar);

	// Set selected behavior
	changeTest(0);
}
 
Example 4
Source File: InventoryUI.java    From Unlucky with MIT License 4 votes vote down vote up
public InventoryUI(final Unlucky game, Player player, final ResourceManager rm) {
    super(game, player, rm);

    ui = new MovingImageUI(rm.inventoryui372x212, new Vector2(200, 7), new Vector2(7, 7), 225.f, 186, 106);
    ui.setTouchable(Touchable.enabled);

    // create exit button
    ImageButton.ImageButtonStyle exitStyle = new ImageButton.ImageButtonStyle();
    exitStyle.imageUp = new TextureRegionDrawable(rm.exitbutton18x18[0][0]);
    exitStyle.imageDown = new TextureRegionDrawable(rm.exitbutton18x18[1][0]);
    exitButton = new ImageButton(exitStyle);
    exitButton.setSize(9, 9);

    // Fonts and Colors
    Label.LabelStyle[] labelColors = new Label.LabelStyle[] {
        new Label.LabelStyle(rm.pixel10, new Color(1, 1, 1, 1)), // white
        new Label.LabelStyle(rm.pixel10, new Color(0, 190 / 255.f, 1, 1)), // blue
        new Label.LabelStyle(rm.pixel10, new Color(1, 212 / 255.f, 0, 1)), // yellow
        new Label.LabelStyle(rm.pixel10, new Color(0, 1, 60 / 255.f, 1)), // green
        new Label.LabelStyle(rm.pixel10, new Color(220 / 255.f, 0, 0, 1)) // red
    };

    // create headers
    headers = new Label[3];
    for (int i = 0; i < headers.length; i++) {
        headers[i] = new Label(headerStrs[i], labelColors[0]);
        headers[i].setSize(62, 4);
        headers[i].setFontScale(0.5f);
        headers[i].setTouchable(Touchable.disabled);
        headers[i].setAlignment(Align.left);
    }

    // create stats
    stats = new Label[5];
    for (int i = 0; i < stats.length; i++) {
        stats[i] = new Label("", labelColors[0]);
        stats[i].setSize(62, 4);
        stats[i].setFontScale(0.5f);
        stats[i].setTouchable(Touchable.disabled);
        stats[i].setAlignment(Align.left);
    }
    stats[0].setStyle(labelColors[3]);
    stats[1].setStyle(labelColors[4]);
    stats[2].setStyle(labelColors[1]);
    stats[3].setStyle(labelColors[2]);
    stats[4].setStyle(labelColors[2]);

    selectedSlot = new Image(rm.selectedslot28x28);
    selectedSlot.setVisible(false);
    tooltip = new ItemTooltip(rm.skin);
    tooltip.setPosition(90, 15);

    enabled = new ImageButton.ImageButtonStyle();
    enabled.imageUp = new TextureRegionDrawable(rm.invbuttons92x28[0][0]);
    enabled.imageDown = new TextureRegionDrawable(rm.invbuttons92x28[1][0]);
    disabled = new ImageButton.ImageButtonStyle();
    disabled.imageUp = new TextureRegionDrawable(rm.invbuttons92x28[2][0]);
    invButtons = new ImageButton[2];
    invButtonLabels = new Label[2];
    String[] texts = { "ENCHANT", "SELL" };
    for (int i = 0; i < 2; i++) {
        invButtons[i] = new ImageButton(disabled);
        invButtons[i].setTouchable(Touchable.disabled);
        invButtonLabels[i] = new Label(texts[i], labelColors[0]);
        invButtonLabels[i].setFontScale(0.5f);
        invButtonLabels[i].setTouchable(Touchable.disabled);
        invButtonLabels[i].setSize(46, 14);
        invButtonLabels[i].setAlignment(Align.center);
    }

    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            end();
            if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume);
            if (inMenu) {
                removeInventoryActors();
                game.menuScreen.transitionIn = 1;
                renderHealthBars = false;
                game.inventoryScreen.setSlideScreen(game.menuScreen, true);
            }
            else {
                Gdx.input.setInputProcessor(gameScreen.multiplexer);
            }
        }
    });

    handleStageEvents();
    handleInvButtonEvents();
}
 
Example 5
Source File: MainMenuScreen.java    From Bomberman_libGdx with MIT License 4 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 titleLabel = new Label("Bomberman", labelStyle);
    titleLabel.setFontScale(1.6f);
    titleLabel.setPosition(140, 360);

    Label easyLabel = new Label("Easy", labelStyle);
    easyLabel.setPosition((640 - easyLabel.getWidth()) / 2, 240);

    Label normalLabel = new Label("Normal", labelStyle);
    normalLabel.setPosition((640 - normalLabel.getWidth()) / 2, 180);

    Label hardLabel = new Label("Hard", labelStyle);
    hardLabel.setPosition((640 - hardLabel.getWidth()) / 2, 120);

    Pixmap pixmap = new Pixmap(640, 480, Pixmap.Format.RGB888);
    pixmap.setColor(240.0f / 255.0f, 128 / 255.0f, 0, 1.0f);
    pixmap.fill();
    backgroundTexture = new Texture(pixmap);
    pixmap.dispose();
    Image background = new Image(backgroundTexture);

    indicatorX = 160f;
    indicatorY = 240f;

    TextureAtlas textureAtlas = GameManager.getInstance().getAssetManager().get("img/actors.pack", TextureAtlas.class);
    indicator0 = new Image(new TextureRegion(textureAtlas.findRegion("MainMenuLogo"), 0, 0, 40, 26));
    indicator0.setSize(80f, 52f);
    indicator0.setPosition(indicatorX, indicatorY);

    indicator1 = new Image(new TextureRegion(textureAtlas.findRegion("MainMenuLogo"), 40, 0, 40, 26));
    indicator1.setSize(80f, 52f);
    indicator1.setPosition(indicatorX, indicatorY);
    indicator1.setVisible(false);
    
    indicationsTexture = new Texture("img/indications.png");
    indications = new Image(indicationsTexture);
    indications.setPosition(640f - indications.getWidth() - 12f, 12f);

    stage.addActor(background);
    stage.addActor(indications);
    stage.addActor(titleLabel);
    stage.addActor(easyLabel);
    stage.addActor(normalLabel);
    stage.addActor(hardLabel);
    stage.addActor(indicator0);
    stage.addActor(indicator1);

    currentSelection = 0;
    selected = false;
    
    GameManager.getInstance().playMusic("SuperBomberman-Title.ogg", true);
}
 
Example 6
Source File: SteeringBehaviorsTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public void create () {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

	greenFish = new TextureRegion(new Texture("data/green_fish.png"));
	cloud = new TextureRegion(new Texture("data/particle-cloud.png"));
	badlogicSmall = new TextureRegion(new Texture("data/badlogicsmall.jpg"));
	target = new TextureRegion(new Texture("data/target.png"));

	skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	stage = new Stage();
	stage.setDebugAll(DEBUG_STAGE);
	stageWidth = stage.getWidth();
	stageHeight = stage.getHeight();

	Gdx.input.setInputProcessor(new InputMultiplexer(stage));

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stageWidth, stageHeight);
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create test selection window
	Array<List<String>> engineTests = new Array<List<String>>();
	for (int k = 0; k < tests.length; k++) {
		engineTests.add(createTestList(k));
	}
	testSelectionWindow = addTestSelectionWindow("Behaviors", ENGINES, engineTests, 0, -1);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(testHelpLabel = new Label("", skin)).padLeft(15);
	stage.addActor(statusBar);

	// Set selected behavior
	changeTest(0, 0);
}
 
Example 7
Source File: ParallelVsSequenceTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public TestScreen (final ParallelVsSequenceTest test, Skin skin) {
	this.test = test;
	this.skin = skin;
	lastUpdateTime = 0;
	gameOver = false;

	greenFishTextureRegion = new TextureRegion(new Texture("data/green_fish.png"));
	badlogicTextureRegion = new TextureRegion(new Texture("data/badlogicsmall.jpg"));
	targetTextureRegion = new TextureRegion(new Texture("data/target.png"));

	shapeRenderer = new ShapeRenderer();

	stage = new Stage();

	Stack testStack = new Stack();
	stage.addActor(testStack);

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stage.getWidth(), stage.getHeight());
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(new IntValueLabel("Sequence (Fish): ", 0, skin) {
		@Override
		public int getValue () {
			return sequencePredator.score;
		}
	}).padLeft(15);
	statusBar.add(new IntValueLabel("Parallel (Badlogics): ", 0, skin) {
		@Override
		public int getValue () {
			return parallelPredator.score;
		}
	}).padLeft(15);
	stage.addActor(statusBar);

	// Add test table
	testStack.setSize(stage.getWidth(), stage.getHeight());
	testStack.add(testTable = new Table() {
		@Override
		public void act (float delta) {
			float time = GdxAI.getTimepiece().getTime();
			if (lastUpdateTime != time) {
				lastUpdateTime = time;
				super.act(GdxAI.getTimepiece().getDeltaTime());
			}
		}
	});
	testStack.layout();

	this.sheeps = new Array<Sheep>();

	for (int i = 0; i < 30; i++) {
		Sheep sheep = new Sheep(targetTextureRegion);
		sheep.setMaxLinearAcceleration(50);
		sheep.setMaxLinearSpeed(80);
		sheep.setMaxAngularAcceleration(10); // greater than 0 because independent facing is enabled
		sheep.setMaxAngularSpeed(5);

		Wander<Vector2> wanderSB = new Wander<Vector2>(sheep) //
			.setFaceEnabled(true) // We want to use Face internally (independent facing is on)
			.setAlignTolerance(0.001f) // Used by Face
			.setDecelerationRadius(5) // Used by Face
			.setTimeToTarget(0.1f) // Used by Face
			.setWanderOffset(90) //
			.setWanderOrientation(10) //
			.setWanderRadius(40) //
			.setWanderRate(MathUtils.PI2 * 4);
		sheep.setSteeringBehavior(wanderSB);

		setRandomNonOverlappingPosition(sheep, sheeps, 5);
		setRandomOrientation(sheep);

		testTable.addActor(sheep);

		sheeps.add(sheep);
	}

	sequencePredator = createPredator(false);
	parallelPredator = createPredator(true);

	// Create GameOver panel
	gameOverButton = new TextButton("Game Over", skin);
	gameOverButton.setVisible(false);
	gameOverButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			test.backToPreviousScreen();
		}
	});
	testTable.add(gameOverButton);
}
 
Example 8
Source File: ResumeVsJoinTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public TestScreen (final ResumeVsJoinTest test, Skin skin) {
	this.test = test;
	this.skin = skin;
	lastUpdateTime = 0;
	gameOver = false;

	greenFishTextureRegion = new TextureRegion(new Texture("data/green_fish.png"));
	badlogicTextureRegion = new TextureRegion(new Texture("data/badlogicsmall.jpg"));
	targetTextureRegion = new TextureRegion(new Texture("data/target.png"));

	shapeRenderer = new ShapeRenderer();

	stage = new Stage();

	Stack testStack = new Stack();
	stage.addActor(testStack);

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stage.getWidth(), stage.getHeight());
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(new IntValueLabel("Resume (Fish): ", 0, skin) {
		@Override
		public int getValue () {
			return resumePredator.score;
		}
	}).padLeft(15);
	statusBar.add(new IntValueLabel("Join (Badlogics): ", 0, skin) {
		@Override
		public int getValue () {
			return joinPredator.score;
		}
	}).padLeft(15);
	stage.addActor(statusBar);

	// Add test table
	testStack.setSize(stage.getWidth(), stage.getHeight());
	testStack.add(testTable = new Table() {
		@Override
		public void act (float delta) {
			float time = GdxAI.getTimepiece().getTime();
			if (lastUpdateTime != time) {
				lastUpdateTime = time;
				super.act(GdxAI.getTimepiece().getDeltaTime());
			}
		}
	});
	testStack.layout();

	this.sheeps = new Array<Sheep>();

	for (int i = 0; i < 30; i++) {
		Sheep sheep = new Sheep(targetTextureRegion);
		sheep.setMaxLinearAcceleration(50);
		sheep.setMaxLinearSpeed(80);
		sheep.setMaxAngularAcceleration(10); // greater than 0 because independent facing is enabled
		sheep.setMaxAngularSpeed(5);

		Wander<Vector2> wanderSB = new Wander<Vector2>(sheep) //
			.setFaceEnabled(true) // We want to use Face internally (independent facing is on)
			.setAlignTolerance(0.001f) // Used by Face
			.setDecelerationRadius(5) // Used by Face
			.setTimeToTarget(0.1f) // Used by Face
			.setWanderOffset(90) //
			.setWanderOrientation(10) //
			.setWanderRadius(40) //
			.setWanderRate(MathUtils.PI2 * 4);
		sheep.setSteeringBehavior(wanderSB);

		setRandomNonOverlappingPosition(sheep, sheeps, 5);
		setRandomOrientation(sheep);

		testTable.addActor(sheep);

		sheeps.add(sheep);
	}

	resumePredator = createPredator(false);
	joinPredator = createPredator(true);

	// Create GameOver panel
	gameOverButton = new TextButton("Game Over", skin);
	gameOverButton.setVisible(false);
	gameOverButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			test.backToPreviousScreen();
		}
	});
	testTable.add(gameOverButton);
}