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


Java Button.setBounds方法代碼示例

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


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

示例1: StageControl

import com.badlogic.gdx.scenes.scene2d.ui.Button; //導入方法依賴的package包/類
public StageControl() {
	// Config
	config = new ConfigGeneral();
	config.load();
	// Spritebatch
	spritebatch = new SpriteBatch();
	// Screen touchable
	wiiScreen = new Button(new Button.ButtonStyle());
	wiiScreen.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	wiiImage = new Texture("image/placeholder.png");
	addActor(wiiScreen);
	// Initialize controls
	for (Control control : controls)
		control.init(this);
	// Audio
	audioThread = new AudioThread();
	audioThread.start();
	// Video
	videoThread = new VideoThread();
	videoThread.start();
	// Command
	commandThread = new CommandThread();
	commandThread.start();
}
 
開發者ID:rolandoislas,項目名稱:drc-sim-client,代碼行數:25,代碼來源:StageControl.java

示例2: init

import com.badlogic.gdx.scenes.scene2d.ui.Button; //導入方法依賴的package包/類
@Override
public void init(StageControl stage) {
	config = new ConfigTouch();
	config.load();
	// Touchpad
	float x = Gdx.graphics.getWidth() * (100f / 2560);
	float y = Gdx.graphics.getHeight() * (100f / 1440);
	float touchpadWidth = Gdx.graphics.getWidth() * (250f / 2560);
	float touchpadHeight = Gdx.graphics.getHeight() * (250f / 1440);
	Skin touchpadSkin = new Skin();
	touchpadSkin.add("background", new Texture("image/touchpad-background.png"));
	touchpadSkin.add("knob",
			TextureUtil.resizeTexture("image/touchpad-knob.png", touchpadWidth / 2,
					touchpadHeight / 2));
	Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle();
	touchpadStyle.background = touchpadSkin.getDrawable("background");
	touchpadStyle.knob = touchpadSkin.getDrawable("knob");
	touchpad = new Touchpad(10, touchpadStyle);
	touchpad.setBounds(x, y, touchpadWidth, touchpadHeight);
	stage.addActor(touchpad);
	// A Button
	float buttonWidth = touchpadWidth / 2;
	float buttonHeight = touchpadHeight / 2;
	Skin buttonSkin = new Skin();
	buttonSkin.add("up",
			TextureUtil.resizeTexture("image/button-up.png", buttonWidth, buttonHeight));
	buttonSkin.add("down",
			TextureUtil.resizeTexture("image/button-down.png", buttonWidth, buttonHeight));
	TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle();
	buttonStyle.up = buttonSkin.getDrawable("up");
	buttonStyle.down = buttonSkin.getDrawable("down");
	buttonStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
	buttonA = new TextButton("A", buttonStyle);
	buttonA.setPosition(Gdx.graphics.getWidth() - x - buttonWidth, y + buttonHeight);
	stage.addActor(buttonA);
	// B Button
	buttonB = new TextButton("B", buttonStyle);
	buttonB.setPosition(Gdx.graphics.getWidth() - x - 2 * buttonWidth, y);
	stage.addActor(buttonB);
	// X Button
	buttonX = new TextButton("X", buttonStyle);
	buttonX.setPosition(buttonA.getX() - buttonWidth, buttonA.getY() + buttonHeight);
	stage.addActor(buttonX);
	// Y Button
	buttonY = new TextButton("Y", buttonStyle);
	buttonY.setPosition(buttonB.getX() - buttonWidth, buttonB.getY() + buttonHeight);
	stage.addActor(buttonY);
	// Home Button
	buttonHome = new TextButton("H", buttonStyle);
	buttonHome.setPosition(Gdx.graphics.getWidth() / 2 - buttonWidth / 2, 10);
	stage.addActor(buttonHome);
	// Minus Button
	buttonMinus = new TextButton("-", buttonStyle);
	buttonMinus.setPosition(buttonHome.getX() - buttonWidth, buttonHome.getY());
	stage.addActor(buttonMinus);
	// Plus Button
	buttonPlus = new TextButton("+", buttonStyle);
	buttonPlus.setPosition(buttonHome.getX() + buttonWidth, buttonHome.getY());
	stage.addActor(buttonPlus);
	// TODO D-pad
	// Left Trigger
	float triggerWidth = Gdx.graphics.getWidth() * .1f;
	float triggerHeight = Gdx.graphics.getHeight() * .1f;
	if (config.triggersVisible)
		buttonLeftTrigger = new TextButton("L", buttonStyle);
	else
		buttonLeftTrigger = new Button(new Button.ButtonStyle());
	buttonLeftTrigger.setBounds(0, Gdx.graphics.getHeight() - triggerHeight, triggerWidth, triggerHeight);
	stage.addActor(buttonLeftTrigger);
	// Right Trigger
	if (config.triggersVisible)
		buttonRightTrigger = new TextButton("R", buttonStyle);
	else
		buttonRightTrigger = new Button(new Button.ButtonStyle());
	buttonRightTrigger.setBounds(Gdx.graphics.getWidth() - triggerWidth,
			Gdx.graphics.getHeight() - triggerHeight, triggerWidth, triggerHeight);
	stage.addActor(buttonRightTrigger);
}
 
開發者ID:rolandoislas,項目名稱:drc-sim-client,代碼行數:79,代碼來源:ControlTouch.java


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