本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Button.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setName方法的具体用法?Java Button.setName怎么用?Java Button.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.Button
的用法示例。
在下文中一共展示了Button.setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawdefenders
import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void drawdefenders(){
defenders = new DrawDefenders();
groupBtnDefender = new Group();
Button btn1 = new Button(new ImageButton.ImageButtonStyle());
btn1.setName("btn1");
btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
btn1.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
groupBtnDefender.addActor(btn1);
Button btn2 = new Button(new ImageButton.ImageButtonStyle());
btn2.setName("btn2");
btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
btn2.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f);
groupBtnDefender.addActor(btn2);
Button btn3 = new Button(new ImageButton.ImageButtonStyle());
btn3.setName("btn3");
btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
btn3.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
groupBtnDefender.addActor(btn3);
}
示例2: drawAttachers
import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void drawAttachers(){
attachers = new DrawAttachers();
Button btn1 = new Button(new ImageButton.ImageButtonStyle());
btn1.setName("btn4");
btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
btn1.setPosition(Gdx.graphics.getWidth() - btn1.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
groupBtnDefender.addActor(btn1);
Button btn2 = new Button(new ImageButton.ImageButtonStyle());
btn2.setName("btn5");
btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
btn2.setPosition(Gdx.graphics.getWidth() - btn2.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f);
groupBtnDefender.addActor(btn2);
Button btn3 = new Button(new ImageButton.ImageButtonStyle());
btn3.setName("btn6");
btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
btn3.setPosition(Gdx.graphics.getWidth() - btn3.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
groupBtnDefender.addActor(btn3);
}
示例3: getSlotButton
import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
/**
* Creates a button to represent one slot
*
* @param slot
* @return The button to use for one slot
*/
private Button getSlotButton(String slot) {
final Skin skin = ui.getSkin();
final Button button = new Button(new ButtonStyle());
final ButtonStyle style = button.getStyle();
style.up = style.down = skin.getDrawable("black");
String textLabel = I18N.getString("ui.newSlot");
button.setSize(slotWidth, slotHeight);
if (slotExists(slot)) {
button.add(getScreenshot(slot)).maxSize(slotWidth * .95f, slotHeight * .95f);
try {
long l = Long.parseLong(slot);
Date d = new Date(l);
textLabel = (new SimpleDateFormat()).format(d);
} catch (Exception e) {
textLabel = slot;
}
button.addListener(loadClickListener);
} else {
Image fg = new Image(skin.getDrawable("plus"));
button.add(fg).maxSize(slotHeight / 2, slotHeight / 2);
button.addListener(saveClickListener);
}
button.row();
Label label = new Label(textLabel, skin);
label.setAlignment(Align.center);
button.add(label).fillX();
button.setName(slot);
return button;
}
示例4: init
import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void init() {
setColor(getBackgroundColor());
LinearLayout shortRepresentation = new LinearLayout(true);
shortRepresentation.background(style.background)
.backgroundColor(getBackgroundColor()).pad(style.padding);
shortRepresentation.add(new Image(skin.getDrawable(getIcon())));
shortRepresentation.add(getShortRepresenation()).margin(MARGIN, 0,
MARGIN, 0);
shortRepresentation.addSpace();
add(shortRepresentation).expandX();
editor = new LinearLayout(false);
addFieldsEditors();
if (editor.getChildren().size > 0) {
Button editButton = new Button(style.editButton);
editButton.setName(EDIT_BUTTON);
editButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
editor.setVisible(!editor.isVisible());
invalidateHierarchy();
}
});
shortRepresentation.add(editButton);
editor.setVisible(false);
add(editor).expandX().margin(MARGIN);
}
}
示例5: getLevelButton
import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private Button getLevelButton(int level) {
//Create a basic button style that doesn't have any images
ButtonStyle buttonStyle = new ButtonStyle();
Button button = new Button(buttonStyle);
levelButtonMap.put(level, button);
// Create the label to show the level number
LabelStyle labelStyleActive = skin.get("levelButtons", LabelStyle.class);
labelStyleActive.font = font;
Label label = new Label(Integer.toString(level + 1), labelStyleActive);
label.setAlignment(Align.center);
// Stack the image label on top of eachother
Image buttonImage = new Image(buttonTexture);
button.stack(buttonImage, label).size(64f, 64f);
//set button properties for an active button
if (level <= levelsUnlocked) {
buttonStyle.pressedOffsetX = 1;
buttonStyle.pressedOffsetY = -1;
buttonImage.setColor(ColorUtils.getRandomHSBColor());
//assign a name to the actor based on the level it represents
button.setName(Integer.toString(level));
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setSelectedLevel(Integer.parseInt(event.getListenerActor().getName()));
}
});
button.addListener(buttonListener);
//calculate "star" information
final LevelInfo levelData = LevelInfo.getLevelInfo(level);
float maxDiff = levelData.numTotal - levelData.numNeededToPass;
float earnedDiff = SaveData.getLevelScore(level) - levelData.numNeededToPass;
float perCent = earnedDiff / maxDiff;
int stars = 0;
if (perCent <= 0.20f) {
stars = 1;
} else if (perCent <= 0.60f) {
stars = 2;
} else {
stars = 3;
}
Table starTable = new Table();
starTable.defaults().pad(2f);
if (stars >= 1) {
for (int star = 0; star < MAX_STARS; star++) {
Image image = new Image((stars > star) ? buttonTexture : hollowTexture);
image.setColor(buttonImage.getColor());
starTable.add(image).width(16f).height(16f);
}
}
button.row();
button.add(starTable).height(25f);
} else if (level <= LevelInfo.getNumberOfLevels() - 1) {
buttonImage.setColor(new Color(0.75f, 0.75f, 0.75f, 1)); //existing levels, but are locked
} else { //levels that don't exist that are used for keeping the layout, make them invisible
button.getColor().a = 0f;
}
return button;
}