List of usage examples for com.badlogic.gdx.scenes.scene2d.actions DelayAction DelayAction
public DelayAction(float duration)
From source file:com.ray3k.libraryinvaders.states.MenuState.java
License:Open Source License
private void showCharacterDialog() { Dialog dialog = new Dialog("", skin); Label label = new Label("Choose a character...", skin); dialog.getContentTable().add(label); dialog.getContentTable().row();/*from www . j a va 2 s . c o m*/ Table table = new Table(); ScrollPane scrollPane = new ScrollPane(table, skin); scrollPane.setFadeScrollBars(false); dialog.getContentTable().add(scrollPane).grow(); final ButtonGroup<ImageTextButton> buttons = new ButtonGroup<ImageTextButton>(); for (String name : getCore().getImagePacks().get(DATA_PATH + "/characters")) { Drawable drawable = new TextureRegionDrawable(getCore().getAtlas().findRegion(name)); Image image = new Image(drawable); ImageTextButton imageTextButton = new ImageTextButton(name, skin, "list"); imageTextButton.getImageCell().setActor(image); imageTextButton.getLabelCell().left().expandX(); table.add(imageTextButton).growX(); buttons.add(imageTextButton); table.row(); } dialog.getContentTable().row(); TextButton textButton = new TextButton("OK", skin); dialog.getContentTable().add(textButton); textButton.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { getCore().getAssetManager().get(Core.DATA_PATH + "/sfx/menu.wav", Sound.class).play(); ((GameState) getCore().getStateManager().getState("game")) .setSelectedCharacter(buttons.getChecked().getText().toString()); Gdx.input.setInputProcessor(null); Action changeStateAction = new Action() { @Override public boolean act(float delta) { getCore().getStateManager().loadState("game"); return true; } }; root.addAction(new SequenceAction(new DelayAction(.5f), changeStateAction)); } }); dialog.show(stage); dialog.setSize(600.0f, 500.0f); dialog.setPosition(stage.getWidth() / 2.0f, stage.getHeight() / 2.0f, Align.center); stage.setScrollFocus(scrollPane); }
From source file:com.ray3k.skincomposer.dialog.DialogLoading.java
License:Open Source License
@Override public Dialog show(Stage stage) { Dialog dialog = super.show(stage); RunnableAction runnableAction = new RunnableAction(); runnableAction.setRunnable(() -> { if (runnable != null) { runnable.run();//from w w w . jav a 2 s .co m } hide(); }); Action action = new SequenceAction(new DelayAction(.5f), runnableAction); addAction(action); return dialog; }
From source file:com.ray3k.skincomposer.RootTable.java
License:Open Source License
public void refreshStyleProperties(boolean preserveScroll) { if (stylePropertiesTable != null && stylePropertiesScrollPane != null) { float scrollY; if (preserveScroll) { scrollY = stylePropertiesScrollPane.getScrollY(); } else {/*from www.java 2 s. c om*/ scrollY = 0; } stylePropertiesTable.clearChildren(); addStyleProperties(stylePropertiesTable); if (preserveScroll) { validate(); stylePropertiesScrollPane.setSmoothScrolling(false); stylePropertiesScrollPane.setScrollY(scrollY); stylePropertiesScrollPane.addAction(new SequenceAction(new DelayAction(.1f), new Action() { @Override public boolean act(float delta) { stylePropertiesScrollPane.setSmoothScrolling(true); return true; } })); } } }