本文整理汇总了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);
}
示例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);
}
示例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());
}
示例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));
}
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}