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


Java Touchpad.setBounds方法代码示例

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


在下文中一共展示了Touchpad.setBounds方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: JoystickControl

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public JoystickControl(Texture background, Texture knob, float deadZoneRadius, float x, float y, float width, float height) {
	touchpadSkin = new Skin();
	//Set background image
	touchpadSkin.add("touchBackground", background);
	//Set knob image
	touchpadSkin.add("touchKnob", knob);
	//Create TouchPad Style
	touchpadStyle = new TouchpadStyle();
	//Apply the Drawables to the TouchPad Style
	touchpadStyle.background = touchpadSkin.getDrawable("touchBackground");
	touchpadStyle.knob = touchpadSkin.getDrawable("touchKnob");
	//Create new TouchPad with the created style
	touchpad = new Touchpad(deadZoneRadius, touchpadStyle);
	//setBounds(x,y,width,height)
	touchpad.setBounds(x, y, width, height);
}
 
开发者ID:jmrapp1,项目名称:TerraLegion,代码行数:17,代码来源:JoystickControl.java

示例2: setupUi

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
protected void setupUi() {

        stage = new Stage(uiViewport, batch);
        Gdx.input.setInputProcessor(stage);

        if(Gdx.app.getType() != Application.ApplicationType.Android && Gdx.app.getType() != Application.ApplicationType.iOS) {
            return;
        }

        touchpadSkin = new Skin();
        touchpadSkin.add("touchBackground", new Texture("data/touchBackground.png"));
        touchpadSkin.add("touchKnob", new Texture("data/touchKnob.png"));
        touchpadStyle = new Touchpad.TouchpadStyle();
        touchBackground = touchpadSkin.getDrawable("touchBackground");
        touchKnob = touchpadSkin.getDrawable("touchKnob");

        touchpadStyle.background = touchBackground;
        touchpadStyle.knob = touchKnob;

        touchpad = new Touchpad(10, touchpadStyle);
        touchpad.setBounds(15, 15, 200, 200);

        stage.addActor(touchpad);
    }
 
开发者ID:bholota,项目名称:LibGdxJoystick-test,代码行数:25,代码来源:TouchPadTest.java

示例3: initTouchpad

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
private void initTouchpad() {
        // TODO: use uiskin.json
//        Skin touchpadSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
        Skin touchpadSkin = new Skin();
        touchpadSkin.add("touchBackground", assetService.getTexture(TOUCH_BACKGROUND));
        touchpadSkin.add("touchKnob", assetService.getTexture(TOUCH_KNOB));
        Touchpad.TouchpadStyle style = new Touchpad.TouchpadStyle();

        style.background = touchpadSkin.getDrawable("touchBackground");
        style.knob = touchpadSkin.getDrawable("touchKnob");
        style.knob.setMinHeight(TOUCHPAD_SIZE / 2);
        style.knob.setMinWidth(TOUCHPAD_SIZE / 2);

        touchPad = new Touchpad(15, style);
        touchPad.setBounds(TOUCHPAD_MARGIN, TOUCHPAD_MARGIN, TOUCHPAD_SIZE, TOUCHPAD_SIZE);

        addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
            }
        });
        NoClickZone padZone = new NoClickZone(touchPad, NO_CLICK_MARGIN);
        addActor(padZone);

        touchpadSkin.add("touchButton", assetService.getTexture(TOUCH_KNOB));
        button = new GamepadButton(touchpadSkin.getDrawable("touchButton"));
        button.setSize(BUTTON_SIZE, BUTTON_SIZE);
        NoClickZone buttonZone = new NoClickZone(button, NO_CLICK_MARGIN);
        addActor(buttonZone);
    }
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:32,代码来源:GamepadController.java

示例4: initTouchPad

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
private void initTouchPad() {
	touchpadSkin = new Skin();
	touchpadSkin.add("touchBackground", GameUtils.getGame().assetHandler.get("Controls/touchBackground.png",Texture.class));
	touchpadSkin.add("touchKnob", GameUtils.getGame().assetHandler.get("Controls/touchKnob.png",Texture.class));
	touchpadStyle = new TouchpadStyle();
	touchBackground = touchpadSkin.getDrawable("touchBackground");
	touchKnob = touchpadSkin.getDrawable("touchKnob");
	touchpadStyle.background = touchBackground;
	touchpadStyle.knob = touchKnob;
	touchpad = new Touchpad(10, touchpadStyle);
	touchpad.setBounds(15, 15, 200, 200);
	
}
 
开发者ID:Arcxes,项目名称:CursedEcho,代码行数:14,代码来源:CursedEchoController.java

示例5: touchPadConf

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public void touchPadConf() {
    touchpadSkin = new Skin();
    touchpadSkin.add("touchpadBackground", new Texture("touchpadBackground.png"));
    touchpadSkin.add("touchKnob", new Texture("touchKnob.png"));
    touchpadStyle = new Touchpad.TouchpadStyle();
    touchpadBackground = touchpadSkin.getDrawable("touchpadBackground");
    touchpadKnob = touchpadSkin.getDrawable("touchKnob");

    touchpadStyle.background = touchpadBackground;
    touchpadStyle.knob = touchpadKnob;

    touchpad = new Touchpad(20, touchpadStyle);
    touchpad.setBounds(15, 15 ,150, 150);

}
 
开发者ID:MSLacerda,项目名称:DarkDay,代码行数:16,代码来源:TouchPadConf.java

示例6: TouchpadEntity

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public TouchpadEntity(Stage stage) {
	TouchpadStyle style = new TouchpadStyle();
	style.background = new TextureRegionDrawable(Drawables.skin("ui/joyBack"));
	style.knob = new TextureRegionDrawable(Drawables.skin("ui/joyNub"));
	touchpad = new Touchpad(3, style);
	touchpad.setBounds(40, 20, SIZE, SIZE);
	touchpad.getColor().a = 0;
	stage.addActor(touchpad);
	Game.publisher().subscribe(this);
	Game.publisher().publish(new TouchpadCreatedEvent(touchpad));
}
 
开发者ID:adketuri,项目名称:umbracraft,代码行数:12,代码来源:TouchpadEntity.java

示例7: createTouchpad

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
private void createTouchpad() {
	stage = new Stage();
	TouchpadStyle touchpadStyle = new TouchpadStyle(uiSkin.getDrawable("touchpad-background"), uiSkin.getDrawable("touchpad-knob"));
	stick = new Touchpad(1, touchpadStyle);
	stick.setBounds(15, 15, 100, 100);
	stage.addActor(stick);
}
 
开发者ID:gcleenew,项目名称:RottenCave,代码行数:8,代码来源:GameScreen.java

示例8: createTouchControls

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
private void createTouchControls(){
	
	logger.info("Creating Touchscreen controls");
	
    touchpadSkin = new Skin();
    touchpadSkin.add("touchBackground", App.assets.getTexture("touchBackground.png"));
    touchpadSkin.add("touchKnob", App.assets.getTexture("touchKnob.png"));
    touchpadStyle = new TouchpadStyle();
    touchBackground = touchpadSkin.getDrawable("touchBackground");
    touchKnob = touchpadSkin.getDrawable("touchKnob");
    touchpadStyle.background = touchBackground;
    touchpadStyle.knob = touchKnob;

    moveStick = new Touchpad(10, touchpadStyle);
    moveStick.setBounds(15, 15, 200, 200);
    moveStick.setSize(200, 200);

    fireStick = new Touchpad(10, touchpadStyle);
    fireStick.setBounds(Gdx.graphics.getWidth() - 215, 15, 200, 200);
    fireStick.setSize(200, 200);
 
    //Create a Stage and add TouchPad
    //stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true, batch);
    stage.addActor(moveStick);       
    stage.addActor(fireStick);
    Gdx.input.setInputProcessor(stage);
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:28,代码来源:UserInterface.java

示例9: create

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public void create () {
	stage = new Stage();
	Gdx.input.setInputProcessor(stage);

	Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	touchpad = new Touchpad(20, skin);
	touchpad.setBounds(15, 15, 100, 100);
	stage.addActor(touchpad);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:11,代码来源:TouchpadTest.java

示例10: init

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的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.Touchpad.setBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。