com.badlogic.gdx.scenes.scene2d.ui.Image Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Image. 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: CCSpriteViewTest.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
@Test
@NeedGL
public void shouldParseSpriteView() throws Exception {
    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("animation/MainScene.json"), null, null, null, null);

    Group group = editor.createGroup();
    Image image = group.findActor("st_2");
    Array<Action> actions = image.getActions();
    assertThat(actions.size, is(1));
    RepeatAction repeatAction = (RepeatAction) actions.get(0);
    ParallelAction parallelAction = (ParallelAction) repeatAction.getAction();
    assertThat(parallelAction.getActions().size, is(3));
    assertThat(parallelAction.getActions(), (Matcher) everyItem(instanceOf(SequenceAction.class)));
    SequenceAction moveAction = (SequenceAction) parallelAction.getActions().get(0);
    SequenceAction scaleAction = (SequenceAction) parallelAction.getActions().get(1);
    assertThat(moveAction.getActions().size, is(4));
    assertThat(moveAction.getActions(), (Matcher) everyItem(instanceOf(MoveToAction.class)));
    assertThat(scaleAction.getActions().size, is(4));
    assertThat(scaleAction.getActions(), (Matcher) everyItem(instanceOf(ScaleToAction.class)));
}
 
Example #2
Source File: ShowTutorialArrow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
private void blink(final Image arrow, final ArrowDirection direction) {
if (direction == ArrowDirection.fromTop || direction == ArrowDirection.fromBottom) {
    arrow.addAction(Actions.sequence(
        Actions.moveBy(0, moveOffset(), periodTime() * 0.25f),
        Actions.moveBy(0, -moveOffset() * 2f, periodTime() * 0.5f),
        Actions.moveBy(0, moveOffset(), periodTime() * 0.25f),
        Actions.run(new Runnable() {
            @Override public void run() {
                blink(arrow, direction);
            }
        })
    ));
} else {
    arrow.addAction(Actions.sequence(
        Actions.moveBy(moveOffset(), 0, periodTime() * 0.25f),
        Actions.moveBy(-moveOffset() * 2f, 0 * 2f, periodTime() * 0.5f),
        Actions.moveBy(moveOffset(), 0, periodTime() * 0.25f),
        Actions.run(new Runnable() {
 
Example #3
Source File: CCLoadingBar.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {

    if (widget.getImageFileData() == null) {
        return new Image();
    }

    TextureRegion textureRegion = editor.findTextureRegion(widget, widget.getImageFileData()
            .getPath());
    if (textureRegion == null) {
        return new Image();
    }
    TLoadingBar loadingBar = new TLoadingBar(textureRegion);
    loadingBar.setValue(widget.getProgressInfo());

    return loadingBar;
}
 
Example #4
Source File: Item.java    From Unlucky with MIT License 6 votes vote down vote up
/**
 * For all types of equips
 * Gives increased stats and can be sold for gold
 *
 * @param name
 * @param desc
 * @param type
 * @param rarity
 * @param imgIndex
 * @param mhp
 * @param dmg
 * @param acc
 * @param sell
 */
public Item(ResourceManager rm, String name, String desc, int type, int rarity, int imgIndex, int minLevel, int maxLevel,
            int mhp, int dmg, int acc, int sell) {
    this.name = name;
    this.desc = desc;
    this.type = type;
    this.rarity = rarity;
    this.imgIndex = imgIndex;
    this.minLevel = minLevel;
    this.maxLevel = maxLevel;
    this.mhp = mhp;
    this.dmg = dmg;
    this.acc = acc;
    this.sell = sell;
    actor = new Image(rm.items20x20[type][imgIndex]);
    labelName = name;
}
 
Example #5
Source File: ArrowMessageNet.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected Table getMessageTable() {

        LocLabel label = new LocLabel(locKey);
        label.setWrap(true);
        label.setAlignment(Align.center);

        Label tapToContinue = new LocLabel("tap-to-continue", ShowTutorialMessage.Message.TAP_TO_CONTINUE);
        tapToContinue.setWrap(true);
        tapToContinue.setAlignment(Align.center);

        Table result = new Table();
        result.align(Align.top);
        result.add(label).width(stage.getWidth() / 1.5f).row();
        result.add(new Image(Config.skin, "ui-creature-info-line")).width(120).padTop(4).row();
        result.add(tapToContinue);
        return result;
    }
 
Example #6
Source File: CreatureInfoWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
private ClickListener createListener(final Group group, final Image selection, final LocLabel label, final CreatureEffect effect, final Creature creature) {
    return new ClickListener() {
        @Override public void clicked(InputEvent event, float x, float y) {
            group.addActor(selection);
            final int turnCount = effect.getTurnCount();
            if (turnCount > 1000) {
                //forever effect
                label.setKey("ui-creature-info-window-forever-effect-description");
                label.setParams(Thesaurus.params()
                        .with("desc", effect.locDescKey())
                        .with("die", creature.description.nameLocKey())
                );
            } else {
                label.setKey("ui-creature-info-window-effect-description");
                label.setParams(Thesaurus.params()
                        .with("desc", effect.locDescKey())
                        .with("turn-count", String.valueOf(turnCount))
                        .with("die", creature.description.nameLocKey())
                );
            }
        }
    };
}
 
Example #7
Source File: LoadSaveScreen.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
private Image getScreenshot(String slot) {
	String filename = slot + WorldSerialization.GAMESTATE_EXT + ".png";

	FileHandle savedFile = null;

	if (EngineAssetManager.getInstance().getUserFile(filename).exists())
		savedFile = EngineAssetManager.getInstance().getUserFile(filename);
	else if (EngineAssetManager.getInstance().assetExists("tests/" + filename))
		savedFile = EngineAssetManager.getInstance().getAsset("tests/" + filename);
	else {
		Drawable d = ui.getSkin().getDrawable("black");

		return new Image(d);
	}

	Texture t = new Texture(savedFile);

	// add to the list for proper dispose when hide the screen
	textureList.add(t);

	return new Image(t);
}
 
Example #8
Source File: CraftingPane.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public CraftingPane(int elementsCount, Array<Ability> recipes) {
        super(Config.skin);
        this.inputs = new ObjectMap<Actor, ItemIcon>(elementsCount);
        this.count = elementsCount;
        this.recipes = recipes;
//        defaults().pad(2);
        for (int i = 0; i < elementsCount; i++) {
            Image image = new Image(Config.skin, "ui-crafting-slot");
            image.setName("slot#" + i);
            inputs.put(image, null);
            add(image).size(26);
            if (i != elementsCount - 1) {
                add(new Tile("ui-plus")).pad(1);
            } else {
                add(new Tile("ui-equals")).pad(1);
            }
        }
        add(output).size(26);
        setTouchable(Touchable.enabled);
    }
 
Example #9
Source File: BasicColorPicker.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private VisTable createColorsPreviewTable () {
	VisTable table = new VisTable(false);
	table.add(currentColorImg = new AlphaImage(commons, 5 * sizes.scaleFactor))
			.height(25 * sizes.scaleFactor).width(80 * sizes.scaleFactor).expandX().fillX();
	table.add(new Image(style.iconArrowRight)).pad(0, 2, 0, 2);
	table.add(newColorImg = new AlphaImage(commons, 5 * sizes.scaleFactor))
			.height(25 * sizes.scaleFactor).width(80 * sizes.scaleFactor).expandX().fillX();

	currentColorImg.setColor(color);
	newColorImg.setColor(color);

	currentColorImg.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			restoreLastColor();
		}
	});

	return table;
}
 
Example #10
Source File: AbilityIconCounter.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public AbilityIconCounter(Ability ability, int value) {
    if (ability == null) {
        ability = Config.abilities.get("skip-turn");
    }
    image = new Image(Config.skin.getDrawable("ability/" + ability.name + "-icon"));
    if (ability.cost <0) image.setColor(AbilityIcon.unique);
    image.setScaling(Scaling.none);
    image.setAlign(Align.left | Align.top);
    image.moveBy(0, 1);

    counter = new Label("", Config.skin, "default", "inventory-counter");
    counter.setAlignment(Align.right | Align.bottom);
    setCount(value);

    addActor(image);
    addActor(counter);

    setSize(image.getPrefWidth(), image.getPrefHeight());
}
 
Example #11
Source File: SlotActor.java    From Cubes with MIT License 6 votes vote down vote up
public SlotActor(Inventory inventory, int num) {
  super(new ButtonStyle());

  Image image = new Image();
  image.setScaling(Scaling.fit);
  image.setDrawable(new SlotDrawable());
  image.setTouchable(Touchable.disabled);
  add(image);
  setSize(getPrefWidth(), getPrefHeight());

  this.inventory = inventory;
  this.num = num;

  InventoryManager.newSlot(this);
  addListener(new SlotTooltipListener(this));
}
 
Example #12
Source File: StatusBar.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public StatusBar(final Batch batch, final AssetManager assets) {
	overlay = new Stage(new ScreenViewport(), batch);

	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = assets.get(Assets.HUD_FONT);
	style.font.setFixedWidthGlyphs(NUMBER_GLYPHS);

	collectiblesLabel = new Label(String.format(TWO_DIGITS, 0), style);
	livesLabel = new Label(String.format(TWO_DIGITS, 0), style);
	scoreLabel = new Label(String.format(EIGHT_DIGITS, 0), style);
	timeLabel = new Label(String.format(THREE_DIGITS, 0), style);

	TextureAtlas hudAtlas = assets.get(Assets.NINJA_RABBIT_ATLAS);

	Table table = new Table();
	table.add(new Image(hudAtlas.findRegion(SMALL_CARROT_REGION))).padRight(8.0f);
	table.add(collectiblesLabel).bottom();
	table.add(new Image(hudAtlas.findRegion(LIVES_REGION))).padLeft(15.0f);
	table.add(livesLabel).bottom();
	table.add(scoreLabel).expandX();
	table.add(new Image(hudAtlas.findRegion(TIME_REGION))).padRight(12.0f);
	table.add(timeLabel);
	table.setFillParent(true);
	table.top();
	table.pad(15.0f);

	overlay.addActor(table);
}
 
Example #13
Source File: DieNet.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void highlight(IntArray indices) {
    for (int i = 0; i < indices.size; i++) {
        Vector2 pos = iconPositions[indices.get(i)];
        Image image = new Image(Config.skin, "ui/dice-window/net-selection-selected");
        image.setPosition(pos.x - 2, pos.y - 2);
        addActor(image);
        image.toBack();
        image.getColor().a = 0f;
        blink(image);
        highlights.add(image);
    }
}
 
Example #14
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addBottomOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(-90);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE, y * CELL_SIZE + image.getWidth());
    return image;
}
 
Example #15
Source File: Splash.java    From Skyland with MIT License 5 votes vote down vote up
@Override
public void show() {
    queueAssets();

    splashImage = new Image(new Texture(Gdx.files.internal(Textures.TEXTURE_TOXSICK_LOGO)));
    splashImage.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, Align.center);
    Skyland.STAGE.addActor(splashImage);

    addSplashAnimation();
}
 
Example #16
Source File: RewardWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void rotateContinuously(final Image back) {
    back.addAction(Actions.sequence(
        Actions.rotateBy(-360, 6f, Interpolation.linear),
        Actions.run(new Runnable() {
            @Override public void run() {
                rotateContinuously(back);
            }
        })
    ));
}
 
Example #17
Source File: CCSpriteView.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {

    Drawable tr = editor.findDrawable(widget, widget.getFileData());
    if (tr == null) {
        return new Image();
    }
    Image image = new Image(tr);

    return image;
}
 
Example #18
Source File: DieNet.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void blink(final Image image) {
    image.addAction(Actions.sequence(
        Actions.alpha(0.4f, 0.5f),
        Actions.alpha(0f, 0.5f),
        Actions.run(new Runnable() {
            @Override public void run() {
                blink(image);
            }
        })
    ));
}
 
Example #19
Source File: SelectCreatureToResurrectWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private EventListener createListener(final Creature creature, final TextButton button, final WorldObjectView view, final Image selection) {
    return new ClickListener() {
        @Override public void clicked(InputEvent event, float x, float y) {
            view.addActor(selection);
            selection.toBack();
            selected = creature;
            button.setDisabled(false);
        }
    };
}
 
Example #20
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public void removeSelection(Object key) {
    Array<Image> images = selectionMap.remove(key);
    if (images == null)
        throw new IllegalStateException("there is no selection associated for key " + key);
    for (Image image : images) {
        image.remove();
    }
}
 
Example #21
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public void showSelection(Object key, Array<Grid2D.Coordinate> coordinates, String selectionName) {
    if (selectionMap.containsKey(key))
        throw new IllegalStateException("there is already associated selection with key " + key);
    Drawable drawable = Config.skin.getDrawable(selectionName);
    Array<Image> selections = new Array<Image>();
    for (Grid2D.Coordinate coordinate : coordinates) {
        Image image = new Image(drawable);
        blink(image, 0.2f, 1f);
        image.setPosition(coordinate.x() * CELL_SIZE, coordinate.y() * ViewController.CELL_SIZE);
        selectionLayer.addActor(image);
        selections.add(image);
    }
    selectionMap.put(key, selections);
}
 
Example #22
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(90);
    layer.addActor(image);
    image.setPosition((x + 1) * CELL_SIZE, (y + 1) * CELL_SIZE - image.getWidth());
    return image;
}
 
Example #23
Source File: DieMessageWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void doShow(Params params) {
    label.setKey(params.locKey);
    imageTable.clearChildren();
    Image left = new Image(Config.skin, "ui-tutorial-window-halfline");
    left.setOrigin(left.getWidth() / 2f, left.getHeight() / 2f);
    left.rotateBy(180);
    imageTable.add(left);
    imageTable.add(ViewController.createView(new Creature(params.die, PlayerHelper.defaultProtagonist))).padLeft(2).padRight(2);
    imageTable.add(new Image(Config.skin, "ui-tutorial-window-halfline"));
}
 
Example #24
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addLeftOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(180);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE + image.getWidth(), (y + 1) * CELL_SIZE);
    return image;
}
 
Example #25
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addRightOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setPosition((x + 1) * CELL_SIZE - image.getWidth(), y * CELL_SIZE);
    return image;
}
 
Example #26
Source File: BehaviorTreeTests.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
private void changeTest (int testIndex) {
	// Dispose the previous test (if any)
	if (currentTest != null) currentTest.dispose();

	// Add the new test
	currentTest = tests[testIndex];
	Gdx.app.log("BehaviorTreeTests", "***********************************************");
	Gdx.app.log("BehaviorTreeTests", "Starting test " + currentTest.getName());
	Gdx.app.log("BehaviorTreeTests", "***********************************************");
	String description = currentTest.getDescription();
	if (description != null) {
		Gdx.app.log("BehaviorTreeTests", description);
		Gdx.app.log("BehaviorTreeTests", "***********************************************");
		testDescriptionLabel.setText(description);
	} else {
		testDescriptionLabel.setText("Run the tree, look at the log and see what happens");
	}
	Stack testStack = new Stack() {
		@Override
		public void act (float delta) {
			boolean paused = pauseButton.isChecked();
			getChildren().peek().setVisible(paused);
			if (!paused) {
				// Update AI time
				GdxAI.getTimepiece().update(delta);
				
				// Call super
				super.act(delta);
			}
		}
	};
	testStack.add(currentTest.createActor(skin));
	testStack.add(new Image(skin, "translucent"));
	splitPane.setSecondWidget(testStack);
}
 
Example #27
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopRightCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setRotation(-90);
    image.setPosition(x * CELL_SIZE, (y + 1) * CELL_SIZE);
    return image;
}
 
Example #28
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopLeftCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE, y * CELL_SIZE);
    return image;
}
 
Example #29
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void addBackgroundObject(boolean anywhere) {
    final Image image = new Image(backgroundDrawables.random());
    backgroundLayer.addActor(image);


    float scale = 0.5f * MathUtils.random(1, 2);
    image.setSize(image.getPrefWidth() * scale, image.getPrefHeight() * scale);
    image.setRotation(MathUtils.random(0, 1) * 180);
    image.getColor().a = MathUtils.random(0.1f, 0.3f);

    float w = Math.max(world.stage.getWidth(), root.getWidth() + ViewScroller.LEFT + ViewScroller.RIGHT);
    float h = Math.max(world.stage.getHeight(), root.getHeight() + ViewScroller.TOP + ViewScroller.BOTTOM);

    if (anywhere)
        image.setPosition(-root.getX() + w * MathUtils.random(), -root.getY() + h * MathUtils.random());
    else
        image.setPosition(-root.getX() - image.getWidth(), -root.getY() + h * MathUtils.random());

    image.addAction(Actions.sequence(
        Actions.moveBy(w + image.getWidth() - image.getX(), 0, 15 + MathUtils.random(6)),
        Actions.run(new Runnable() {
            @Override public void run() {
                image.remove();
                addBackgroundObject(false);
            }
        })
    ));
}
 
Example #30
Source File: TabbedPane.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public TabbedPane() {
  clickListener = new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Button button = (Button) event.getListenerActor();
      contentPanel.setActor(map.get(button.getName()));
      notifyTabSwitched(buttons.getChecked().getName(), button.getName());
    }
  };

  add(tabs = new VisTable()).growX().row();
  add(new Image(VisUI.getSkin().getDrawable("list-selection"))).growX().row();
  add(contentPanel = new Container<>()).align(Align.top).row();
}