当前位置: 首页>>代码示例>>Java>>正文


Java Button.setSize方法代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Button.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setSize方法的具体用法?Java Button.setSize怎么用?Java Button.setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.scenes.scene2d.ui.Button的用法示例。


在下文中一共展示了Button.setSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:20,代码来源:ScreenCombat.java

示例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);
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:19,代码来源:ScreenCombat.java

示例3: createMobileMoveButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void createMobileMoveButton() {
    float screenWidth = Gdx.graphics.getWidth();
    float screenHeight = Gdx.graphics.getHeight();

    moveButton = new Button(skin);
    moveButton.getStyle().down = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_DOWN_COLOR);
    moveButton.getStyle().up = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_UP_COLOR);
    moveButton.setSize(screenWidth * 0.35f, screenHeight * 0.2f);
    moveButton.setPosition(screenWidth / 32, screenHeight / 32f);
    moveButton.addListener(new com.badlogic.gdx.scenes.scene2d.InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            boolean isTutorial = DAO.getInstance().getBoolean(DAO.IS_NEW_KEY, true);
            if (Globals.getGameState() == Game.State.WAIT_FOR_INPUT) {
                Globals.setGameState(Game.State.RUNNING);
            }

            if (Globals.getGameState() == Game.State.RUNNING) {
                movePointer = pointer;
            }
            return true;
        }
    });

    stage.addActor(moveButton);
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:27,代码来源:HUD.java

示例4: 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

示例5: setArcadeButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public Button setArcadeButton(Drawable d){
    Button.ButtonStyle bts = new Button.ButtonStyle(d,d,d);
    Button arcadeButton = new Button(bts);
    arcadeButton.setSize(WIDTH/4, 3*(HEIGHT/4));
    return arcadeButton;
}
 
开发者ID:naomiHauret,项目名称:OdysseeDesMaths,代码行数:7,代码来源:GameChoiceMenu.java

示例6: initialize

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
@Override
	protected void initialize() {
		fontTexture = new Texture(
				Gdx.files.internal("fonts/ConsolaMono-Bold.png"));
		fontTexture.setFilter(TextureFilter.Linear,
				TextureFilter.MipMapLinearLinear);
		TextureRegion fontRegion = new TextureRegion(fontTexture);
//		font = new BitmapFont(Gdx.files.internal("fonts/ConsolaMono-Bold.fnt"),
//				fontRegion, false);
		font = FontManager.getFontHalf();
		scoreFont = new BitmapFont(Gdx.files.internal("fonts/ConsolaMono-Bold.fnt"),
				fontRegion, false);
		
		pixel = SpriteManager.getSprite("pixel");
		pauseButtonAtlas = SpriteManager.getSprite("pause");
		pauseButtonPressedAtlas = SpriteManager.getSprite("pause-pressed");
		menuButtonAtlas = SpriteManager.getSprite("pause-menu-button");
		menuButtonPressedAtlas = SpriteManager.getSprite("pause-menu-button-pressed");
        
        stage.setViewport(Constants.FRAME_WIDTH, Constants.FRAME_HEIGHT, true);
        
        TextButtonStyle style = new TextButtonStyle();
        style.up = new TextureRegionDrawable(pauseButtonAtlas);
        style.down = new TextureRegionDrawable(pauseButtonPressedAtlas);
        style.font = font;
        style.fontColor = new Color(1, 0, 0, 1);
        pauseButton = new Button(style);
        pauseButton.setSize(30, 30);
        pauseButton.setPosition(15, 10);
		pauseButton.addListener(new InputListener() {
			@Override
			public boolean touchDown(InputEvent event, float x, float y,
					int pointer, int button) {
				gameController.pause();
				return true;
			}
		});
        stage.addActor(pauseButton);
        
        totalScoreLabelStyle = new LabelStyle();
        totalScoreGroup = new Group();
        font.setScale(0.5f);
        totalScoreLabelStyle.font = font;
        totalScore = new Label("Score: 0", totalScoreLabelStyle);
        totalScore.setScale(0.1f);
        totalScore.setPosition(totalScoreX, totalScoreY);
        totalScoreGroup.addActor(totalScore);
        stage.addActor(totalScoreGroup);
        
        scoreLabelStyle = new LabelStyle();
        scoreLabelStyle.font = scoreFont;
        scoreGroup = new Group();
        score = new Label("", scoreLabelStyle);
        score.setPosition(scoreX, scoreY);
        scoreGroup.addActor(score);
        stage.addActor(scoreGroup);
        
        stage.addActor(new EnergyBarActor());
        
        animationAction = new MoveToAction();
        animationAction.setPosition(totalScoreX, totalScoreY + 50);
        animationAction.setDuration(0.5f);
        
        currentScoreState = TextState.HIDDEN;
        
        pauseMenu = new PauseMenu();
        stage.addActor(pauseMenu);
        pauseMenu.setVisible(false);
        
        gameOverMenu = new GameOverMenu();
        stage.addActor(gameOverMenu);
        gameOverMenu.setVisible(false);
	}
 
开发者ID:matachi,项目名称:skuttande-nyan-cat,代码行数:74,代码来源:HudRenderSystem.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.Button.setSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。