當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.row方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.ui.Button.row方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.row方法的具體用法?Java Button.row怎麽用?Java Button.row使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.scenes.scene2d.ui.Button的用法示例。


在下文中一共展示了Button.row方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
}
 
開發者ID:bladecoder,項目名稱:bladecoder-adventure-engine,代碼行數:46,代碼來源:LoadSaveScreen.java

示例2: 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;
}
 
開發者ID:Talon876,項目名稱:explosions,代碼行數:66,代碼來源:LevelSelectron.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.Button.row方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。