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); }
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); }
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)); }
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); }
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); }
public void resetProperties() { properties.clear(); if (clazz.equals(Button.class)) { newStyleProperties(ButtonStyle.class); } else if (clazz.equals(CheckBox.class)) { newStyleProperties(CheckBoxStyle.class); properties.get("checkboxOn").optional = false; properties.get("checkboxOff").optional = false; properties.get("font").optional = false; } else if (clazz.equals(ImageButton.class)) { newStyleProperties(ImageButtonStyle.class); } else if (clazz.equals(ImageTextButton.class)) { newStyleProperties(ImageTextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(Label.class)) { newStyleProperties(LabelStyle.class); properties.get("font").optional = false; } else if (clazz.equals(List.class)) { newStyleProperties(ListStyle.class); properties.get("font").optional = false; properties.get("fontColorSelected").optional = false; properties.get("fontColorUnselected").optional = false; properties.get("selection").optional = false; } else if (clazz.equals(ProgressBar.class)) { newStyleProperties(ProgressBarStyle.class); //Though specified as optional in the doc, there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(ScrollPane.class)) { newStyleProperties(ScrollPaneStyle.class); } else if (clazz.equals(SelectBox.class)) { newStyleProperties(SelectBoxStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; properties.get("scrollStyle").optional = false; properties.get("scrollStyle").value = "default"; properties.get("listStyle").optional = false; properties.get("listStyle").value = "default"; } else if (clazz.equals(Slider.class)) { newStyleProperties(SliderStyle.class); //Though specified as optional in the doc, there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(SplitPane.class)) { newStyleProperties(SplitPaneStyle.class); properties.get("handle").optional = false; } else if (clazz.equals(TextButton.class)) { newStyleProperties(TextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(TextField.class)) { newStyleProperties(TextFieldStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; } else if (clazz.equals(TextTooltip.class)) { newStyleProperties(TextTooltipStyle.class); properties.get("label").optional = false; properties.get("label").value = "default"; } else if (clazz.equals(Touchpad.class)) { newStyleProperties(TouchpadStyle.class); } else if (clazz.equals(Tree.class)) { newStyleProperties(TreeStyle.class); properties.get("plus").optional = false; properties.get("minus").optional = false; } else if (clazz.equals(Window.class)) { newStyleProperties(WindowStyle.class); properties.get("titleFont").optional = false; } }