本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton类的典型用法代码示例。如果您正苦于以下问题:Java ImageTextButton类的具体用法?Java ImageTextButton怎么用?Java ImageTextButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageTextButton类属于com.badlogic.gdx.scenes.scene2d.ui包,在下文中一共展示了ImageTextButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initButtons
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
private void initButtons() {
buttonTexture = new Texture("buttons/button.png");
downButtonTexture = new Texture("buttons/button-down.png");
ImageTextButton.ImageTextButtonStyle style = new ImageTextButton.ImageTextButtonStyle();
style.font = buttonFont;
style.up = new SpriteDrawable(new Sprite(buttonTexture));
style.down = new SpriteDrawable(new Sprite(downButtonTexture));
startButton = new ImageTextButton(" Iniciar ", style);
stage.addActor(startButton);
startButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
// Evento do botão
game.setScreen(new GameScreen(game));
}
});
}
示例2: getImageButtonStyle
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
/**
* Erstellt einen ImageTextButtonStyle anhand eines Button Stils.
*
* @param color
* Der Button Stil
* @return Das ImageTextButtonStyle Objekt
*/
private static ImageTextButtonStyle getImageButtonStyle(
final ButtonColor color) {
Drawable drawable = new TextureRegionDrawable(
AssetManager.getTextureRegion("ui", color.getFileName()));
ImageTextButtonStyle imageButtonStyle = new ImageTextButton.ImageTextButtonStyle();
imageButtonStyle.down = drawable;
imageButtonStyle.up = drawable;
imageButtonStyle.font = AssetManager.getTextFont(color.getFontSize());
imageButtonStyle.fontColor = color.getFontColor();
return imageButtonStyle;
}
示例3: addGameButton
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
/**
* Fügt einen neuen Button für ein Spiel hinzu.
*
* @param gameObject
* Spiel Infos.
*/
private void addGameButton(final GameObject gameObject) {
ImageTextButton imgTextButton = new ButtonLarge(gameObject.getGameTitle(), ButtonColor.LIGHT_BROWN);
imgTextButton.addListener(new ChangeListener() {
public void changed(final ChangeEvent event, final Actor actor) {
Gdx.app.log("DEBUG", "Spiel " + gameObject.getGameTitle() + " soll gestartet werden");
GameManagerFactory.getInstance().navigateToLevel(gameObject.getLevelID());
}
});
verticalGroup.addActor(imgTextButton);
imgTextButton.setPosition(this.width / 2 - imgTextButton.getWidth() / 2, lastButtonY);
lastButtonY = (int) (lastButtonY - imgTextButton.getHeight());
stage.addActor(imgTextButton);
imgTextButton.toFront();
}
示例4: createButton
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
/**
* Erzeugt den LadeButtonText.
*/
private void createButton() {
Drawable drawable = new TextureRegionDrawable((new TextureRegion(new Texture(
Gdx.files.internal("splashscreen/buttonBackground.png")))));
FreeTypeFontGenerator gen = new FreeTypeFontGenerator(
Gdx.files.internal("fonts/textfont/Grundschrift-Bold.ttf"));
FreeTypeFontParameter frontPara = new FreeTypeFontParameter();
frontPara.size = 40;
BitmapFont b = gen.generateFont(frontPara);
gen.dispose();
ImageTextButtonStyle imageButtonStyle = new ImageTextButton.ImageTextButtonStyle();
imageButtonStyle.down = drawable;
imageButtonStyle.up = drawable;
imageButtonStyle.font = b;
imageButtonStyle.fontColor = Color.valueOf("877E6A");
textContent = new ImageTextButton("Lade... : ", imageButtonStyle);
}
示例5: UserPanel
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
public UserPanel(int x, int y, int width, int height) {
super(x, y, width, height);
userlevelButton = new ImageTextButton("" + GDefence.getInstance().user.getLevel(), GDefence.getInstance().assetLoader.getUserLevelSkin());
//userlevelButton.getLabel().setFontScale(1.5f);
int userLevelSize[] = {width/4, width/4};
//userlevelButton.setSize(userLevelSize[0], userLevelSize[1]);
//userlevelButton.setPosition();
// userlevelButton.addListener(new InputListener() {
// public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// return true;
// }
// }
// );
int expBarSize[] = {width, height - userLevelSize[1]};
ExpBar bar = new ExpBar(expBarSize[0], expBarSize[1]);
//add(new GoldPanel(mainClass)).width(width/6*2).height(height);
add(userlevelButton).width(userLevelSize[0]).height(userLevelSize[1]).row();
add(bar);
//System.out.println(getY());
}
示例6: process
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final ImageTextButton actor,
final String rawAttributeData) {
final ImageTextButtonStyle style = new ImageTextButtonStyle(actor.getStyle());
style.imageUp = parser.getData().getDefaultSkin().getDrawable(parser.parseString(rawAttributeData, actor));
actor.setStyle(style);
}
示例7: handlePlainTextLine
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
@Override
protected void handlePlainTextLine(final String plainTextLine) {
final ImageTextButton button = (ImageTextButton) getActor();
final String textToAppend = getParser().parseString(plainTextLine, getActor());
if (Strings.isEmpty(button.getText())) {
button.setText(textToAppend);
} else {
if (LmlUtilities.isMultiline(button)) {
button.setText(button.getText().toString() + '\n' + textToAppend);
} else {
button.setText(button.getText().toString() + textToAppend);
}
}
}
示例8: createButtons
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
/**
* erstelle drei Buttons(vor, zurück und ok) setze jeweils die Größe und die
* Position fest. srufe die Methode addListener(...) auf füge alle drei in
* die erste Stage
*
*/
private void createButtons() {
ButtonSmall buttonNext = new ButtonSmall(ButtonType.RIGHT);
ButtonSmall buttonPrev = new ButtonSmall(ButtonType.LEFT);
Drawable buttonImg = new TextureRegionDrawable(
AssetManager.getTextureRegion("ui", "panel_brown"));
this.buttonOk = new ButtonOwnTextImage("OK",
new ImageTextButton.ImageTextButtonStyle(
new TextButton.TextButtonStyle(buttonImg, buttonImg, buttonImg,
AssetManager.getTextFont(FontSize.FORTY))));
buttonOk.setHeight(80);
buttonOk.setWidth(300);
buttonNext.setPosition(width - buttonNext.getWidth() - 5, height / 2);
buttonPrev.setPosition(5, height / 2);
buttonOk.setPosition(myXPos + myWidth / 2 - buttonOk.getWidth() / 2,
myYPos + myHeight + 5);
blinc(buttonOk);
buttonNext.setName("next");
buttonPrev.setName("prev");
buttonPrev.setName("ok");
addListener(buttonNext, buttonOk, buttonPrev);
firststage.addActor(buttonNext);
firststage.addActor(buttonPrev);
firststage.addActor(buttonOk);
}
示例9: initButtons
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
/**
* Erstellt die Buttons.
*/
private void initButtons() {
buttonsSpiel = new ImageTextButton[3];
Map<Integer, String> games = SaveGameManager.getSaveGameList();
Iterator<Integer> gamesIterator = games.keySet().iterator();
ImageTextButton buttonSpiel;
String buttonText;
int gameID = 0;
for (int i = 0; i < 3; i++) {
if (gamesIterator.hasNext()) {
gameID = gamesIterator.next();
buttonText = games.get(gameID);
} else {
gameID = (games.containsKey(i)) ? 2 * i : i;
buttonText = "Neue Spielerin";
}
buttonSpiel = new ButtonLarge(buttonText, ButtonLarge.ButtonColor.LIGHT_BROWN);
table.addActor(buttonSpiel);
buttonSpiel.toFront();
addButtonSpielListener(buttonSpiel, gameID);
buttonsSpiel[i] = buttonSpiel;
}
// der Credits-Button
buttonCredits = new ButtonLarge("Credits", ButtonLarge.ButtonColor.LIGHT_BROWN);
table.addActor(buttonCredits);
buttonCredits.toFront();
}
示例10: showCharacterDialog
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
private void showCharacterDialog() {
Dialog dialog = new Dialog("", skin);
Label label = new Label("Choose a character...", skin);
dialog.getContentTable().add(label);
dialog.getContentTable().row();
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/coin.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(400.0f, 400.0f);
dialog.setPosition(stage.getWidth() / 2.0f, stage.getHeight() / 2.0f, Align.center);
stage.setScrollFocus(scrollPane);
}
示例11: resetProperties
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
public void resetProperties() {
properties.clear();
if (clazz.equals(Button.class)) {
newStyleProperties(ButtonStyle.class);
} else if (clazz.equals(CheckBox.class)) {
newStyleProperties(CheckBoxStyle.class);
properties.get("checkboxOn").optional = false;
properties.get("checkboxOff").optional = false;
properties.get("font").optional = false;
} else if (clazz.equals(ImageButton.class)) {
newStyleProperties(ImageButtonStyle.class);
} else if (clazz.equals(ImageTextButton.class)) {
newStyleProperties(ImageTextButtonStyle.class);
properties.get("font").optional = false;
} else if (clazz.equals(Label.class)) {
newStyleProperties(LabelStyle.class);
properties.get("font").optional = false;
} else if (clazz.equals(List.class)) {
newStyleProperties(ListStyle.class);
properties.get("font").optional = false;
properties.get("fontColorSelected").optional = false;
properties.get("fontColorUnselected").optional = false;
properties.get("selection").optional = false;
} else if (clazz.equals(ProgressBar.class)) {
newStyleProperties(ProgressBarStyle.class);
//Though specified as optional in the doc, there are bugs without "background" being mandatory
properties.get("background").optional = false;
} else if (clazz.equals(ScrollPane.class)) {
newStyleProperties(ScrollPaneStyle.class);
} else if (clazz.equals(SelectBox.class)) {
newStyleProperties(SelectBoxStyle.class);
properties.get("font").optional = false;
properties.get("fontColor").optional = false;
properties.get("scrollStyle").optional = false;
properties.get("scrollStyle").value = "default";
properties.get("listStyle").optional = false;
properties.get("listStyle").value = "default";
} else if (clazz.equals(Slider.class)) {
newStyleProperties(SliderStyle.class);
//Though specified as optional in the doc, there are bugs without "background" being mandatory
properties.get("background").optional = false;
} else if (clazz.equals(SplitPane.class)) {
newStyleProperties(SplitPaneStyle.class);
properties.get("handle").optional = false;
} else if (clazz.equals(TextButton.class)) {
newStyleProperties(TextButtonStyle.class);
properties.get("font").optional = false;
} else if (clazz.equals(TextField.class)) {
newStyleProperties(TextFieldStyle.class);
properties.get("font").optional = false;
properties.get("fontColor").optional = false;
} else if (clazz.equals(TextTooltip.class)) {
newStyleProperties(TextTooltipStyle.class);
properties.get("label").optional = false;
properties.get("label").value = "default";
} else if (clazz.equals(Touchpad.class)) {
newStyleProperties(TouchpadStyle.class);
} else if (clazz.equals(Tree.class)) {
newStyleProperties(TreeStyle.class);
properties.get("plus").optional = false;
properties.get("minus").optional = false;
} else if (clazz.equals(Window.class)) {
newStyleProperties(WindowStyle.class);
properties.get("titleFont").optional = false;
}
}
示例12: getHandledType
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
@Override
public Class<ImageTextButton> getHandledType() {
return ImageTextButton.class;
}
示例13: getNewInstanceOfActor
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
@Override
protected Actor getNewInstanceOfActor(final LmlActorBuilder builder) {
final TextLmlActorBuilder textBuilder = (TextLmlActorBuilder) builder;
return new ImageTextButton(textBuilder.getText(), getSkin(builder), builder.getStyleName());
}
示例14: getComponentActors
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
@Override
protected Actor[] getComponentActors(final Actor actor) {
final ImageTextButton button = (ImageTextButton) actor;
return new Actor[] { button.getImage(), button.getLabel() };
}
示例15: createButton
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; //导入依赖的package包/类
/**
* Diese Methode erzeugt einen Button.
*
* @param label
* Button Text
* @param inputListener
* {@link ChangeListener} um auf den Button Klick zu reagieren
* @return button
*/
private ImageTextButton createButton(final String label, final ChangeListener inputListener) {
ImageTextButton btn = new ButtonLarge(label, inputListener);
btn.addListener(inputListener);
this.addActor(btn);
return btn;
}