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


Java Touchpad类代码示例

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


Touchpad类属于com.badlogic.gdx.scenes.scene2d.ui包,在下文中一共展示了Touchpad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setup

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入依赖的package包/类
public static void setup(){
	registerSerializer(Actor.class, new ActorSerializer());
	registerSerializer(Scene.class, new SceneSerializer());
	registerSerializer(ImageJson.class, new ImageJson());
	registerSerializer(Label.class, new LabelSerializer());
	registerSerializer(Button.class, new ButtonSerializer());
	registerSerializer(TextButton.class, new TextButtonSerializer());
	registerSerializer(Table.class, new TableSerializer());
	registerSerializer(CheckBox.class, new CheckBoxSerializer());
	registerSerializer(SelectBox.class, new SelectBoxSerializer());
	registerSerializer(List.class, new ListSerializer());
	registerSerializer(Slider.class, new SliderSerializer());
	registerSerializer(TextField.class, new TextFieldSerializer());
	registerSerializer(Touchpad.class, new TouchpadSerializer());
	registerSerializer(Sprite.class, new SpriteSerializer());
	
	registerSerializer(Dialog.class, new DialogSerializer());
	registerSerializer(SplitPane.class, new SplitPaneSerializer());
	registerSerializer(ScrollPane.class, new ScrollPaneSerializer());
	registerSerializer(Stack.class, new StackSerializer());
	registerSerializer(Tree.class, new TreeSerializer());
	registerSerializer(Table.class, new TableSerializer());
	registerSerializer(ButtonGroup.class, new ButtonGroupSerializer());
	registerSerializer(HorizontalGroup.class, new HorizontalGroupSerializer());
	registerSerializer(VerticalGroup.class, new VerticalGroupSerializer());
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:27,代码来源:Serializer.java

示例4: resize

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入依赖的package包/类
@Override
public void resize(int width, int height) {
    super.resize(width, height);
    world = new World(game);
    controller = new WorldController(game, world);
    renderer = new WorldRenderer(game, world);
    renderer.resize(width, height);

    stats = GuiBuilder.buildStats(stage.getWidth(), 100 * ScaleUtil.getSizeRatio(), game.getResourcesManager().getStyles(), game.getResourcesManager());
    stats.setBounds(0, height - height / 7, width, height / 7);
    stage.addActor(stats);

    if (game.getPreferencesManager().touchPadEnabled) {
        Touchpad touchPad = GuiBuilder.buildTouchPad(350 * ScaleUtil.getSizeRatio(), 350 * ScaleUtil.getSizeRatio(), game.getResourcesManager().getStyles(), controller);
        stage.addActor(touchPad);
    } else {
        stage.addActor(GuiBuilder.buildPadButtons(370 * ScaleUtil.getSizeRatio(), 190 * ScaleUtil.getSizeRatio(), game.getResourcesManager().getStyles(), controller));
    }
}
 
开发者ID:Rubentxu,项目名称:DreamsLibGdx,代码行数:20,代码来源:GameScreen.java

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

示例6: changed

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入依赖的package包/类
@Override
public void changed(ChangeEvent event, Actor actor) {
    Touchpad touchpad = (Touchpad) actor;
    float knobPercentX = touchpad.getKnobPercentX();
    float knobPercentY = touchpad.getKnobPercentY();
    controllerInputHandler.accelerate(knobPercentX, knobPercentY);
    event.handle();
    event.stop();
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:10,代码来源:GamepadController.java

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

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

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

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

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

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

示例13: createActor

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入依赖的package包/类
public void createActor(String type){
	switch(type){
		case "Label":
			if(Asset.fontMap.size != 0){
				LabelStyle ls = new LabelStyle();
				ls.font = Asset.fontMap.firstValue();
				Label label = new Label("Text", ls);
				setName(label);
			}
			break;
		case "Image":
			if(Asset.texMap.size != 0){
				setName(new ImageJson(Asset.texMap.firstKey()));
			}
			break;
		case "Texture":setName(new ImageJson(Content.assetPanel.list.getSelectedValue()));break;
		case "Sprite":setName(new Sprite(1f, Asset.texMap.firstKey()));break;
		case "Particle":
			//ParticleEffect pe = new ParticleEffect();
			//pe.load(effectFile, imagesDir);
			break;

		case "Button":setName(new Button(Asset.skin));break;
		case "TextButton":setName(new TextButton("Text", Asset.skin));break;
		case "TextField":setName(new TextField("", Asset.skin));break;
		case "Table":setName(new Table(Asset.skin));break;
		case "CheckBox":setName(new CheckBox("Check", Asset.skin));break;
		case "SelectBox":setName(new SelectBox(new String[]{"First","Second","Third"}, Asset.skin));break;
		case "List":setName(new List(new String[]{"First","Second","Third"}, Asset.skin));break;
		case "Slider":setName(new Slider(0, 10, 1, false, Asset.skin));break;
		case "Dialog":setName(new Dialog("Title", Asset.skin));break;
		case "Touchpad":setName(new Touchpad(5, Asset.skin));break;
		case "Map":setName(new Map(1, 24));break;
		case "None":break;
		default:break;
	}
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:38,代码来源:StudioPanel.java

示例14: read

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入依赖的package包/类
@Override
public Actor read(Json json, JsonValue jv, Class arg2) {
	Touchpad tp = new Touchpad(jv.getFloat("deadzoneRadius"), Asset.skin);
	deadZoneRadius = jv.getFloat("deadzoneRadius");
	readActor(jv, tp);
	return tp;
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:8,代码来源:Serializer.java

示例15: buildTouchPad

import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入依赖的package包/类
public static final Touchpad buildTouchPad(float width,float height, Styles styles, final WorldController controller) {
    Touchpad touchpad = new Touchpad(10* ScaleUtil.getSizeRatio(), styles.skin);
    touchpad.setPosition(25 * ScaleUtil.getSizeRatio(), 15);
    touchpad.setWidth(width);
    touchpad.setHeight(height);

    touchpad.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            System.out.println("PercentX "+((Touchpad) actor).getKnobPercentX()+"PercentY "+((Touchpad) actor).getKnobPercentY());
            if (((Touchpad) actor).getKnobPercentX() == 0 || ((Touchpad) actor).getKnobPercentX() < 0.5
                    && ((Touchpad) actor).getKnobPercentX() > -0.5) {
                controller.rightReleased();
                controller.leftReleased();
            }
            if (((Touchpad) actor).getKnobPercentX() > 0.5) {
                controller.rightPressed();
                controller.leftReleased();
            }
            if (((Touchpad) actor).getKnobPercentX() < -0.5){
                controller.leftPressed();
                controller.rightReleased();
            }
            if (((Touchpad) actor).getKnobPercentY() > 0.5) {
                controller.jumpPressed();
            } else {
                controller.jumpReleased();
            }

        }
    });

    return touchpad;
}
 
开发者ID:Rubentxu,项目名称:DreamsLibGdx,代码行数:35,代码来源:GuiBuilder.java


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