Java Code Examples for com.badlogic.gdx.scenes.scene2d.Group#addActor()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.Group#addActor() .
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: GroupLayout.java From libgdx-snippets with MIT License | 6 votes |
@Override protected Actor create(Skin skin, StageLayoutListener listener) { Group group = (Group)super.create(skin, listener); for(int i=0; i<actors.size; i++){ ActorLayout layout = actors.get(i); group.addActor(layout.create(skin, listener)); } if(sizeToActor != null){ Actor actor = group.findActor(sizeToActor); if(actor != null){ group.setWidth(actor.getWidth()); group.setHeight(actor.getHeight()); } } else { if(layout.width > 0) group.setWidth(layout.width); if(layout.height > 0) group.setHeight(layout.height); } return group; }
Example 2
Source File: WindowManager.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
void add(GameWindow window) { if (windows.contains(window, true)) return; Group parent; if (window.getTargetParent() != null) { if (window.getTargetParent().getStage() == null) throw new IllegalStateException("no stage in target parent to show window!"); parent = window.getTargetParent(); } else { if (activeStage == null) throw new IllegalStateException("no active stage to show window!"); parent = activeStage.getRoot(); } windows.add(window); parent.addActor(window); }
Example 3
Source File: CreatureInfoWindow.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
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 4
Source File: DropVisualizer.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
@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 5
Source File: SelectAbilityWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private ClickListener createListener(final Ability ability, final TextButton button, final Image itemSelection, final Group icon, final LocLabel itemDescriptionLabel) { return new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selected = ability; icon.addActor(itemSelection); itemSelection.toBack(); button.setDisabled(false); itemDescriptionLabel.setParams(Thesaurus.params().with("name", ability.locNameKey()).with("desc", ability.locDescKey())); } }; }
Example 6
Source File: GroupParser.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
/** * 解析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 7
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static Tile addTopRightCorner(int x, int y, String name, Group layer) { TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-corner-top-right").random(); if (region == null) return null; Tile image = new Tile(region); layer.addActor(image); image.setPosition(x * CELL_SIZE, y * CELL_SIZE); return image; }
Example 8
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static Image addBottomLeftCornerTransition(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 + 1) * CELL_SIZE, (y) * CELL_SIZE); return image; }
Example 9
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private Tile addImageToLayer(Group layer, float imageX, float imageY, String imageName) { // Image image = new Image(Config.skin, imageName); // image.setPosition(imageX, imageY); Tile tile = new Tile(imageName); tile.setPosition(imageX, imageY); layer.addActor(tile); return tile; }
Example 10
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static Image addOverHang(int x, int y, String name, String type, Group layer) { TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-overhang-" + type).random(); if (region == null) { region = Config.findRegions("tile/" + name + "-overhang").random(); if (region == null) return null; } Image image = new Image(region); layer.addActor(image); image.setPosition(x * CELL_SIZE, (y + 1) * CELL_SIZE - image.getHeight()); return image; }
Example 11
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static Tile addTopLeftCorner(int x, int y, String name, Group layer) { TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-corner-top-left").random(); if (region == null) return null; Tile image = new Tile(region); layer.addActor(image); image.setPosition((x + 1) * CELL_SIZE - image.getWidth(), y * CELL_SIZE); return image; }
Example 12
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
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 13
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
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 14
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static Tile addBottomLeftCorner(int x, int y, String name, Group layer) { TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-corner-bottom-left").random(); if (region == null) return null; Tile image = new Tile(region); layer.addActor(image); image.setPosition((x + 1) * CELL_SIZE - image.getWidth(), (y + 1) * CELL_SIZE - image.getHeight()); return image; }
Example 15
Source File: WorldSelectScreen.java From Unlucky with MIT License | 4 votes |
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 16
Source File: LevelSelectScreen.java From Unlucky with MIT License | 4 votes |
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 17
Source File: T.java From cocos-ui-libgdx with Apache License 2.0 | 4 votes |
public T addTo(Group parent) { parent.addActor(actor); return this; }
Example 18
Source File: SelectScreen.java From Unlucky with MIT License | 4 votes |
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 19
Source File: TImage.java From cocos-ui-libgdx with Apache License 2.0 | 4 votes |
public TImage add(Group group) { group.addActor(this); return this; }
Example 20
Source File: Hud.java From Unlucky with MIT License | 4 votes |
/** * 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); }