当前位置: 首页>>代码示例>>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;未经允许,请勿转载。