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


Java CheckBox.CheckBoxStyle方法代碼示例

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


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

示例1: addCheckboxStyles

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //導入方法依賴的package包/類
private void addCheckboxStyles() {
    Texture sheet = game.manager.get("ui/switch.png");
    int width = sheet.getWidth();
    int height = sheet.getHeight() / 3;
    TextureRegion broken = new TextureRegion(sheet, 0, 0, width, height);
    TextureRegion on = new TextureRegion(sheet, 0, height, width, height);
    TextureRegion off = new TextureRegion(sheet, 0, 2 * height, width, height);

    CheckBox.CheckBoxStyle style = new CheckBox.CheckBoxStyle();
    style.checkboxOn = new TextureRegionDrawable(on);
    style.checkboxOff = new TextureRegionDrawable(off);
    style.checkboxOnDisabled = style.checkboxOffDisabled = new TextureRegionDrawable(broken);
    style.font = get("normal", BitmapFont.class);
    add("default", style);
}
 
開發者ID:danirod,項目名稱:rectball,代碼行數:16,代碼來源:RectballSkin.java

示例2: init

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //導入方法依賴的package包/類
private void init() {
	//開始界麵控件初始化
	mAtlas = MyGdxGame.assetManager.getTextureAtlas(Constant.START_SETTING);
	mRangeAtlas = MyGdxGame.assetManager.getTextureAtlas(Constant.RANGE_WIDGET);
	mStartBtn = new ImageButton(new TextureRegionDrawable(mAtlas.findRegion("startBtnUp")),
			new TextureRegionDrawable(mAtlas.findRegion("startBtnDown")));

	mSettingBtn = new ImageButton(new TextureRegionDrawable(mAtlas.findRegion("settingBtnUp")),
			new TextureRegionDrawable(mAtlas.findRegion("settingBtnDown")));
	mStartBtn.setSize(280, 100);
	mSettingBtn.setSize(280, 100);
	//輸入姓名對話框
	mInputnameDialog = new InputnameDialog(MyGdxGame.VIEW_WIDTH / 2, MyGdxGame.VIEW_HEIGHT / 2);
	//警告對話框
	mWarningDialog = new NameWarningDialog(MyGdxGame.SCREEN_WIDTH / 2, MyGdxGame.SCREEN_HEIGHT / 2);

	//開始界麵 - 排行榜
	mRangeBtn = new ImageButton(new TextureRegionDrawable(mRangeAtlas.findRegion("rangeBtnUp")),
			new TextureRegionDrawable(mRangeAtlas.findRegion("rangeBtnDown")));
	mRangeBtn.setSize(280, 100);
	//初始化排行榜對話框
	mRangeDialog = new RankingDialog(MyGdxGame.SCREEN_WIDTH / 2, MyGdxGame.SCREEN_HEIGHT / 2);

	mStartBtn.setPosition(MyGdxGame.VIEW_WIDTH / 2 + 20, MyGdxGame.VIEW_HEIGHT / 2 - mStartBtn.getHeight() / 2 - 20);
	mRangeBtn.setPosition(MyGdxGame.VIEW_WIDTH / 2 + 26, MyGdxGame.VIEW_HEIGHT / 2 - mStartBtn.getHeight() / 2 - 100);
	mSettingBtn.setPosition(MyGdxGame.VIEW_WIDTH / 2 + 26, MyGdxGame.VIEW_HEIGHT / 2 - mStartBtn.getHeight() / 2 - 180);

	//設置界麵初始化 - 是否打開音效
	Drawable checkOn = new TextureRegionDrawable(mAtlas.findRegion("musicBtnOn"));
	Drawable checkOff = new TextureRegionDrawable(mAtlas.findRegion("musicBtnOff"));
	CheckBox.CheckBoxStyle boxStyle = new CheckBox.CheckBoxStyle(checkOff, checkOn,
			MyGdxGame.assetManager.getFont(), Color.BLUE);
	mCheckBox = new CheckBox("", boxStyle);
	mCheckBox.setSize(255, 100);
	mCheckBox.setPosition(MyGdxGame.VIEW_WIDTH / 2 + 38, MyGdxGame.VIEW_HEIGHT / 2 - mStartBtn.getHeight() / 2 - 40);
	if (isPlay) {
		mCheckBox.setChecked(true);
	} else {
		mCheckBox.setChecked(false);
	}

	//設置界麵初始化 - 關於我們
	mAboutBtn = new ImageButton(new TextureRegionDrawable(mAtlas.findRegion("aboutBtnUp")),
			new TextureRegionDrawable(mAtlas.findRegion("aboutBtnDown")));
	mAboutBtn.setSize(280, 100);
	mAboutBtn.setPosition(MyGdxGame.VIEW_WIDTH / 2 + 26, MyGdxGame.VIEW_HEIGHT / 2 - mStartBtn.getHeight() / 2 - 110);
	mAboutGameDialog = new AboutGameDialog(MyGdxGame.SCREEN_WIDTH / 2, MyGdxGame.SCREEN_HEIGHT / 2);

	//設置界麵初始化 - 返回按鈕
	mBackButton = new ImageButton(new TextureRegionDrawable(mAtlas.findRegion("backStartBtnUp")),
			new TextureRegionDrawable(mAtlas.findRegion("backStartBtnDown")));
	mBackButton.setSize(280, 100);
	mBackButton.setPosition(MyGdxGame.VIEW_WIDTH / 2 + 26, MyGdxGame.VIEW_HEIGHT / 2 - mStartBtn.getHeight() / 2 - 180);

	//背景音樂
	if (isPlay) {
		MyGdxGame.assetManager.getMusic(Constant.START_BGM).play();
	} else {
		MyGdxGame.assetManager.getMusic(Constant.START_BGM).pause();
	}

	//初始化監聽
	initListener();
}
 
開發者ID:heyzqt,項目名稱:libGdx-xiyou,代碼行數:65,代碼來源:Start.java

示例3: makeCustomGUISkin

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //導入方法依賴的package包/類
private static void makeCustomGUISkin() {
	ResolutionIndependentAtlas skinAtlas = new ResolutionIndependentAtlas(Gdx.files.internal("hud/skin.txt"));

	int size = 4;
	NinePatchDrawable buttonNormal = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("button"), size, size, size, size));
	NinePatchDrawable buttonDown = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("button-down"), size, size, size, size));
	NinePatchDrawable buttonDisabled = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("button"), size, size, size, size));
	buttonDisabled.getPatch().getColor().a = 0.75f;

	customSkin = new Skin();

	CheckBox.CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle();
	checkBoxStyle.checkboxOn = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("checkbox-on")));
	checkBoxStyle.checkboxOff = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("checkbox-off")));
	checkBoxStyle.font = FontManager.Default.getFont();
	checkBoxStyle.fontColor = Color.WHITE;
	customSkin.add("default", checkBoxStyle);

	Slider.SliderStyle sliderStyle = new Slider.SliderStyle(new NinePatchDrawable(new NinePatch(new Texture(WHITE_SWATCH), Color.LIGHT_GRAY)),
			new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("slider-handle"))));
	customSkin.add("default-horizontal", sliderStyle);

	TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = buttonNormal;
	textButtonStyle.font = FontManager.Roboto18.getFont();
	textButtonStyle.fontColor = Color.WHITE;
	textButtonStyle.down = buttonDown;
	textButtonStyle.downFontColor = Color.WHITE;
	textButtonStyle.disabled = buttonDisabled;

	customSkin.add("default", textButtonStyle);

	textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = buttonNormal;
	textButtonStyle.font = FontManager.Roboto18.getFont();
	textButtonStyle.fontColor = Color.WHITE;
	textButtonStyle.down = buttonDown;
	textButtonStyle.downFontColor = Color.WHITE;
	textButtonStyle.checked = buttonDown;
	textButtonStyle.checkedFontColor = Color.WHITE;

	customSkin.add("toggle-button", textButtonStyle);

	TextField.TextFieldStyle textFieldStyle = new TextField.TextFieldStyle();
	textFieldStyle.background = buttonNormal;
	textFieldStyle.font = FontManager.Roboto18.getFont();
	textFieldStyle.fontColor = Color.WHITE;
	textFieldStyle.messageFont = FontManager.Roboto18.getFont();
	textFieldStyle.messageFontColor = Color.LIGHT_GRAY;
	textFieldStyle.cursor = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("text-cursor"), size, size, size, size));
	textFieldStyle.selection = new NinePatchDrawable(new NinePatch(skinAtlas.findRegion("text-selection")));

	customSkin.add("default", textFieldStyle);

	SelectBox.SelectBoxStyle selectBoxStyle = new SelectBox.SelectBoxStyle();
	selectBoxStyle.background = buttonNormal;
	selectBoxStyle.font = FontManager.Roboto18.getFont();
	selectBoxStyle.fontColor = Color.WHITE;
	selectBoxStyle.listStyle = new List.ListStyle();
	selectBoxStyle.background = buttonNormal;
	selectBoxStyle.listStyle.selection = buttonDown;

	customSkin.add("default", selectBoxStyle);
}
 
開發者ID:frigidplanet,項目名稱:droidtowers,代碼行數:65,代碼來源:TowerAssetManager.java

示例4: createStyles

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //導入方法依賴的package包/類
public void createStyles(ResourcesManager resourcesManager) {
    if (!initialize) {
        initialize=true;
        font = resourcesManager.get(resourcesManager.DEFAULT_FONT);
        font.setScale(ScaleUtil.getSizeRatio());
        font.setUseIntegerPositions(false);
        font2 = resourcesManager.get(resourcesManager.HEADER_FONT);
        font2.setScale(ScaleUtil.getSizeRatio());
        font2.setUseIntegerPositions(false);
        skin = new Skin();
        skin.add("default", font);
        skin.add("header", font2);

        skin.add("lt-blue", new Color(.62f, .76f, .99f, 1f));
        skin.add("lt-green", new Color(.39f, .9f, .6f, 1f));
        skin.add("dark-blue", new Color(.79f, .95f, 91f, 1f));

        skin.addRegions(resourcesManager.<TextureAtlas>get(resourcesManager.GUI_ATLAS));
        skin.addRegions(resourcesManager.<TextureAtlas>get(resourcesManager.GUI_PACK_ATLAS));


        TextureRegionDrawable touchpad_background = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.GUI_ATLAS)).findRegion("touchpad_background"));
        TextureRegionDrawable touchpad_thumb = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.GUI_ATLAS)).findRegion("touchpad_thumb"));


        TextureRegionDrawable checkox_true = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("check-on"));

        TextureRegionDrawable checkox_false = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("check-off"));

        TextureRegionDrawable slider_knob = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("default-slider-knob"));
        TextureRegionDrawable slider = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("default-slider"));

        CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle(checkox_false, checkox_true, font, Color.WHITE);


        SpriteDrawable stats = new SpriteDrawable(new Sprite((Texture) resourcesManager.get(resourcesManager.STATS_BACKGROUND)));


        SliderStyle sliderStyle = new SliderStyle(slider, slider_knob);
        skin.add("default",new WindowStyle(font2,Color.ORANGE,skin.getDrawable("debug")));
        skin.add("stats", stats);


        LabelStyle lbs = new LabelStyle();
        lbs.font = font;
        lbs.fontColor = Color.WHITE;
        skin.add("default", lbs);

        LabelStyle lbsHeader = new LabelStyle();
        lbsHeader.font = font2;
        lbsHeader.fontColor = Color.WHITE;
        skin.add("header", lbsHeader);

        TextButtonStyle tbs = new TextButtonStyle(skin.getDrawable("btnMenu"), skin.getDrawable("btnMenuPress"), skin.getDrawable("btnMenu"), font);
        tbs.fontColor = skin.getColor("dark-blue");
        tbs.pressedOffsetX = Math.round(1f * Gdx.graphics.getDensity());
        tbs.pressedOffsetY = tbs.pressedOffsetX * -1f;

        ImageButton.ImageButtonStyle ImageButtonLeft = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonLeft"), skin.getDrawable("buttonLeftPress"),
                skin.getDrawable("buttonLeft"), null, null, null);
        ImageButton.ImageButtonStyle ImageButtonRight = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonRight"), skin.getDrawable("buttonRightPress"),
                skin.getDrawable("buttonRight"), null, null, null);
        ImageButton.ImageButtonStyle ImageButtonUp = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonUp"), skin.getDrawable("buttonUpPress"),
                skin.getDrawable("buttonUp"), null, null, null);


        Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle();
        touchpadStyle.background = touchpad_background;
        touchpadStyle.knob = touchpad_thumb;


        skin.add("default", tbs);
        skin.add("buttonLeft", ImageButtonLeft);
        skin.add("buttonRight", ImageButtonRight);
        skin.add("buttonUp", ImageButtonUp);
        skin.add("default", touchpadStyle);
        skin.add("default", checkBoxStyle);
        skin.add("default-horizontal", sliderStyle);
    }
}
 
開發者ID:Rubentxu,項目名稱:DreamsLibGdx,代碼行數:81,代碼來源:Styles.java


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