Java Code Examples for com.badlogic.gdx.scenes.scene2d.Group#setTransform()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.Group#setTransform() . 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: DropVisualizer.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override public IFuture<Void> visualize(DroppedItem drop) {
    final Future<Void> future = new Future<Void>();

    Group group = new Group();
    Tile image = new Tile("item/" + drop.item.name);
    Label counter = new Label(String.valueOf(drop.count), Config.skin);
    counter.setSize(image.getWidth(), image.getHeight());
    counter.setAlignment(Align.right | Align.bottom);
    group.addActor(image);
    group.addActor(counter);
    group.setTransform(false);
    visualizer.viewController.notificationLayer.addActor(group);
    group.setPosition(drop.target.getX() * ViewController.CELL_SIZE, drop.target.getY() * ViewController.CELL_SIZE);
    group.addAction(Actions.parallel(
        Actions.moveBy(0, 30, 1f, Interpolation.fade),
        Actions.alpha(0, 1f, Interpolation.fade),
        Actions.delay(0.4f, Actions.run(new Runnable() {
            @Override public void run() {
                future.happen();
            }
        }))
    ));
    return future;
}
 
Example 2
Source File: StepDetectorSubView.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public StepDetectorSubView(final StepDetector stepDetector) {
    this.stepDetector = stepDetector;

    off = new Tile("step-detector/" + stepDetector.worldObjectName + "-off");
    offGlow = new Tile("step-detector/" + stepDetector.worldObjectName + "-glow");

    on = new Tile("step-detector/" + stepDetector.worldObjectName + "-on");
    onGlow = new Tile("step-detector/" + stepDetector.worldObjectName + "-on-glow");

    group = new Group() {
        @Override protected void setStage(Stage stage) {
            if (getStage() == null && stage != null) {
                stepDetector.activeState.addListener(StepDetectorSubView.this, false);
            } else if (getStage() != null && stage == null) {
                stepDetector.activeState.removeListener(StepDetectorSubView.this);
            }
            super.setStage(stage);
            final boolean active = stepDetector.activeState.getState();
            onGroup.getColor().a = active ? 1 : 0;
            offGroup.getColor().a = active ? 0 : 1;
        }
    };
    group.setTransform(false);

    group.addActor(offGroup);
    group.addActor(onGroup);

    initGlow(off, offGlow, offGroup);
    initGlow(on, onGlow, onGroup);
}
 
Example 3
Source File: StepDetectorSubView.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void initGlow(Tile a, Tile b, Group group) {
    move(a);
    move(b);
    a.addAction(forever(sequence(alpha(0, 1), alpha(1, 1))));
    b.getColor().a = 0f;
    b.addAction(forever(sequence(alpha(1, 1), alpha(0, 1))));
    group.addActor(a);
    group.addActor(b);
    group.setTransform(false);
}
 
Example 4
Source File: GroupParser.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
/**
 * 解析group控件,当前控件类型为Group的时候处理与Widget类型处理不同
 */
public Group groupChildrenParse(CocoStudioUIEditor editor,
                                ObjectData widget, Group parent, Actor actor) {

    Group group = (Group) actor;

    // Group 虽然自己不接收事件,但是子控件得接收
    actor.setTouchable(widget.isTouchEnable() ? Touchable.enabled
        : Touchable.childrenOnly);
    // 必须设置Transform 为true 子控件才会跟着旋转.

    // group.setTransform(true);

    if (widget.getScale() != null || widget.getRotation() != 0) {
        group.setTransform(true);
    }

    for (ObjectData childrenWidget : widget.getChildren()) {
        Actor childrenActor = editor.parseWidget(group, childrenWidget);
        if (childrenActor == null) {
            continue;
        }
        group.addActor(childrenActor);
    }
    sort(widget, group);

    return group;

}
 
Example 5
Source File: Hud.java    From Unlucky with MIT License 4 votes vote down vote up
/**
 * Creates the death screen message
 */
private void createDeathPrompt() {
    deathGroup = new Group();
    deathGroup.setTransform(false);
    deathGroup.setVisible(false);
    deathGroup.setSize(Unlucky.V_WIDTH, Unlucky.V_HEIGHT);
    deathGroup.setTouchable(Touchable.enabled);

    dark = new Image(rm.shade);
    deathGroup.addActor(dark);

    frame = new Image(rm.skin, "textfield");
    frame.setSize(100, 60);
    frame.setPosition(Unlucky.V_WIDTH / 2 - 50, Unlucky.V_HEIGHT / 2 - 30);
    deathGroup.addActor(frame);

    youDied = new Label("YOU DIED!", new Label.LabelStyle(rm.pixel10, Color.RED));
    youDied.setSize(100, 10);
    youDied.setPosition(50, 75);
    youDied.setAlignment(Align.center);
    youDied.setTouchable(Touchable.disabled);
    deathGroup.addActor(youDied);

    loss = new Label("", new Label.LabelStyle(rm.pixel10, Color.WHITE));
    loss.setFontScale(0.5f);
    loss.setWrap(true);
    loss.setSize(100, 40);
    loss.setAlignment(Align.top);
    loss.setPosition(Unlucky.V_WIDTH / 2 - 50, Unlucky.V_HEIGHT / 2 - 30);
    loss.setTouchable(Touchable.disabled);
    deathGroup.addActor(loss);

    // click to continue
    deathGroup.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume);
            backToMenu();
        }
    });

    stage.addActor(deathGroup);
}
 
Example 6
Source File: SpecialMoveScreen.java    From Unlucky with MIT License 4 votes vote down vote up
/**
 * Creates the scroll pane displaying all the special moves, icons and descs
 */
private void createScrollPane() {
    scrollTable = new Table();
    scrollTable.setFillParent(true);
    stage.addActor(scrollTable);
    selectionContainer = new Table();

    ButtonGroup bg = new ButtonGroup();
    bg.setMaxCheckCount(1);
    bg.setMinCheckCount(0);

    for (int i = 0; i < Util.SMOVES_ORDER_BY_LVL.length; i++) {
        SpecialMove smove = Util.SMOVES_ORDER_BY_LVL[i];
        Group smoveGroup = new Group();
        smoveGroup.setSize(80, 30);
        smoveGroup.setTransform(false);

        Image frame = new Image(rm.smoveFrame);
        frame.setPosition(3, 7);
        frame.setTouchable(Touchable.disabled);
        Image icon = new Image(smove.icon.getDrawable());
        icon.setPosition(4, 8);
        icon.setTouchable(Touchable.disabled);
        Label name = new Label(smove.name, headerStyle);
        name.setFontScale(0.5f);
        name.setPosition(20, 20);
        name.setTouchable(Touchable.disabled);
        Label desc = new Label(smove.desc, white);
        desc.setFontScale(0.5f);
        desc.setPosition(20, 6);
        desc.setTouchable(Touchable.disabled);
        Label status;
        // green label if unlocked
        if (player.getLevel() >= smove.levelUnlocked) status = new Label("UNLOCKED", green);
        // red label with level to unlock
        else status = new Label("UNLOCKED AT LV." + smove.levelUnlocked, red);
        status.setFontScale(0.5f);
        status.setPosition(20, 3);
        status.setTouchable(Touchable.disabled);

        final TextButton button = new TextButton("", rm.skin);
        button.setFillParent(true);
        button.setTouchable(player.getLevel() >= smove.levelUnlocked ?
            Touchable.enabled : Touchable.disabled);
        bg.add(button);
        addScrollPaneEvents(button, smove);

        smoveGroup.addActor(button);
        smoveGroup.addActor(frame);
        smoveGroup.addActor(icon);
        smoveGroup.addActor(name);
        smoveGroup.addActor(desc);
        smoveGroup.addActor(status);

        selectionContainer.add(smoveGroup).padBottom(2).size(80, 30).row();
    }
    selectionContainer.pack();
    selectionContainer.setTransform(false);
    selectionContainer.setOrigin(selectionContainer.getWidth() / 2,
        selectionContainer.getHeight() / 2);

    scrollPane = new ScrollPane(selectionContainer, rm.skin);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setFadeScrollBars(true);
    // remove scroll bar
    scrollPane.setupFadeScrollBars(0, 0);
    scrollPane.layout();
    scrollTable.add(scrollPane).size(120, 80).fill();
    scrollTable.setPosition(-48, -12);
}
 
Example 7
Source File: SelectScreen.java    From Unlucky with MIT License 4 votes vote down vote up
public SelectScreen(final Unlucky game, final ResourceManager rm) {
    super(game, rm);

    // init enter button
    enterButtonGroup = new Group();
    enterButtonGroup.setSize(79, 28);
    enterButtonGroup.setTransform(false);

    nameStyles = new Label.LabelStyle[3];
    nameStyles[0] = new Label.LabelStyle(rm.pixel10, new Color(0, 225.f / 255, 0, 1));
    nameStyles[1] = new Label.LabelStyle(rm.pixel10, new Color(200 / 225.f, 0, 0, 1));
    nameStyles[2] = new Label.LabelStyle(rm.pixel10, new Color(150 / 255.f, 1, 1, 1));

    ImageButton.ImageButtonStyle enterStyle = new ImageButton.ImageButtonStyle();
    enterStyle.imageUp = new TextureRegionDrawable(rm.enterButton[0][0]);
    enterStyle.imageDown = new TextureRegionDrawable(rm.enterButton[1][0]);
    enterButton = new ImageButton(enterStyle);

    enterLabel = new Label("ENTER", new Label.LabelStyle(rm.pixel10, new Color(79 / 255.f, 79 / 255.f, 117 / 255.f, 1)));
    enterLabel.setTouchable(Touchable.disabled);
    enterLabel.setSize(79, 28);
    enterLabel.setAlignment(Align.center);
    enterLabel.setFontScale(1.5f);

    enterButtonGroup.addActor(enterButton);
    enterButtonGroup.addActor(enterLabel);

    // create title label
    banner = new Image(rm.skin, "default-slider");
    banner.setPosition(7, 102);
    banner.setSize(101, 12);
    stage.addActor(banner);

    bannerLabel = new Label("", rm.skin);
    bannerLabel.setStyle(new Label.LabelStyle(rm.pixel10, new Color(1, 212 / 255.f, 0, 1)));
    bannerLabel.setSize(50, 12);
    bannerLabel.setTouchable(Touchable.disabled);
    bannerLabel.setPosition(10, 102);
    bannerLabel.setAlignment(Align.left);
    stage.addActor(bannerLabel);

    // create side description
    descField = new Image(rm.skin, "default-slider");
    descField.setPosition(114, 36);
    descField.setSize(79, 64);
    stage.addActor(descField);

    fullDescLabel = new Label("", new Label.LabelStyle(rm.pixel10, Color.WHITE));
    fullDescLabel.setPosition(118, 40);
    fullDescLabel.setSize(75, 56);
    fullDescLabel.setTouchable(Touchable.disabled);
    fullDescLabel.setFontScale(0.5f);
    fullDescLabel.setWrap(true);
    fullDescLabel.setAlignment(Align.topLeft);
    stage.addActor(fullDescLabel);
}
 
Example 8
Source File: LevelSelectScreen.java    From Unlucky with MIT License 4 votes vote down vote up
protected void createScrollPane() {
    scrollButtons = new Array<TextButton>();

    nameStyle = new Label.LabelStyle(rm.pixel10, Color.WHITE);
    descStyle = new Label.LabelStyle(rm.pixel10, Color.WHITE);
    buttonSelected = new TextButton.TextButtonStyle();
    buttonSelected.up = new TextureRegionDrawable(rm.skin.getRegion("default-round-down"));

    scrollTable = new Table();
    scrollTable.setFillParent(true);
    stage.addActor(scrollTable);

    selectionContainer = new Table();
    for (int i = 0; i < numLevels; i++) {
        final int index = i;

        // button and label group
        Group g = new Group();
        g.setSize(90, 20);
        g.setTransform(false);

        Level l = rm.worlds.get(worldIndex).levels[index];

        Label name;
        // on last level (boss level) the name is red
        if (i == numLevels - 1)
            name = new Label(l.name, new Label.LabelStyle(rm.pixel10, new Color(225 / 255.f, 0, 0, 1)));
        else
            name = new Label(l.name, nameStyle);
        name.setPosition(5, 10);
        name.setFontScale(0.66f);
        name.setTouchable(Touchable.disabled);
        Label desc = new Label("Average level: " + l.avgLevel, descStyle);
        desc.setPosition(5, 4);
        desc.setFontScale(0.5f);
        desc.setTouchable(Touchable.disabled);

        final TextButton b = new TextButton("", rm.skin);
        b.getStyle().checked = b.getStyle().down;
        b.getStyle().over = null;
        if (i == currentLevelIndex) b.setChecked(true);

        // only enable the levels the player has defeated
        if (index > numLevelsToShow) {
            b.setTouchable(Touchable.disabled);
            name.setText("???????????????");
            desc.setText("Average level:  ???");
        }
        else {
            b.setTouchable(Touchable.enabled);
            scrollButtons.add(b);
            name.setText(l.name);
            desc.setText("Average level: " + l.avgLevel);
        }

        // select level
        b.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                if (!game.player.settings.muteSfx) rm.invselectclick.play(game.player.settings.sfxVolume);
                currentLevelIndex = index;
                selectAt(currentLevelIndex);
                String levelName = rm.worlds.get(worldIndex).levels[currentLevelIndex].name;
                fullDescLabel.setText(levelName + "\n\n" + playerStats);
            }
        });
        b.setFillParent(true);

        g.addActor(b);
        g.addActor(name);
        g.addActor(desc);

        selectionContainer.add(g).padBottom(4).size(90, 20).row();
    }
    selectionContainer.pack();
    selectionContainer.setTransform(false);
    selectionContainer.setOrigin(selectionContainer.getWidth() / 2,
        selectionContainer.getHeight() / 2);

    scrollPane = new ScrollPane(selectionContainer, rm.skin);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.layout();
    scrollTable.add(scrollPane).size(112, 93).fill();
    scrollTable.setPosition(-38, -10);
}
 
Example 9
Source File: WorldSelectScreen.java    From Unlucky with MIT License 4 votes vote down vote up
protected void createScrollPane() {
    scrollButtons = new Array<TextButton>();

    descStyle = new Label.LabelStyle(rm.pixel10, Color.WHITE);
    buttonSelected = new TextButton.TextButtonStyle();
    buttonSelected.up = new TextureRegionDrawable(rm.skin.getRegion("default-round-down"));

    scrollTable = new Table();
    scrollTable.setFillParent(true);
    stage.addActor(scrollTable);

    selectionContainer = new Table();
    for (int i = 0; i < rm.worlds.size; i++) {
        final int index = i;

        // button and label group
        Group g = new Group();
        g.setSize(90, 30);
        g.setTransform(false);

        Label name = new Label(rm.worlds.get(i).name, nameStyles[i]);
        name.setPosition(5, 20);
        name.setFontScale(1.7f / 2);
        name.setTouchable(Touchable.disabled);
        Label desc = new Label(rm.worlds.get(i).shortDesc, descStyle);
        desc.setPosition(5, 6);
        desc.setFontScale(0.5f);
        desc.setTouchable(Touchable.disabled);

        final TextButton b = new TextButton("", rm.skin);
        b.getStyle().checked = b.getStyle().down;
        b.getStyle().over = null;
        if (i == 0) b.setChecked(true);

        b.setTouchable(Touchable.enabled);
        scrollButtons.add(b);

        name.setText(rm.worlds.get(i).name);
        desc.setText(rm.worlds.get(i).shortDesc);

        // select world
        b.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                if (!game.player.settings.muteSfx) rm.invselectclick.play(game.player.settings.sfxVolume);
                worldIndex = index;
                selectAt(worldIndex);
                fullDescLabel.setText(rm.worlds.get(worldIndex).longDesc);
            }
        });
        b.setFillParent(true);

        g.addActor(b);
        g.addActor(name);
        g.addActor(desc);

        selectionContainer.add(g).padBottom(4).size(90, 30).row();
    }
    selectionContainer.pack();
    selectionContainer.setTransform(false);
    selectionContainer.setOrigin(selectionContainer.getWidth() / 2,
        selectionContainer.getHeight() / 2);

    scrollPane = new ScrollPane(selectionContainer, rm.skin);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.layout();
    scrollTable.add(scrollPane).size(112, 101).fill();
    scrollTable.setPosition(-38, -10);
}
 
Example 10
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
private void initLayer(Group layer) {
    layer.setSize(world.width * CELL_SIZE, world.height * CELL_SIZE);
    layer.setTransform(false);
}