com.badlogic.gdx.scenes.scene2d.ui.Touchpad Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Touchpad. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JoystickControl.java    From TerraLegion with MIT License 6 votes vote down vote up
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);
}
 
Example #2
Source File: GameScreen.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void create() {
    if (created) return;
    created = true;

    isDebug = DEBUG && Gdx.app.getType() == Application.ApplicationType.Desktop;

    if (DEBUG_TOUCHPAD || Gdx.app.getType() == Application.ApplicationType.Android) {
      touchpad = new Touchpad(10, new Touchpad.TouchpadStyle() {{
        //background = new TextureRegionDrawable(Riiablo.assets.get(touchpadBackgroundDescriptor));
        background = null;
        knob = new TextureRegionDrawable(Riiablo.assets.get(touchpadKnobDescriptor));
      }});
      touchpad.setSize(164, 164);
      touchpad.setPosition(0, mobilePanel != null ? mobilePanel.getHeight() : 0);
      stage.addActor(touchpad);
      if (!DEBUG_TOUCHPAD) touchpad.toBack();
    }

    // TODO: sort children based on custom indexes
    controlPanel.toFront();
    output.toFront();
    if (mobilePanel != null) mobilePanel.toFront();
//  if (mobileControls != null) mobileControls.toFront();
    if (touchpad != null) touchpad.toBack();
    input.toFront();
    escapePanel.toFront();

    if (Gdx.app.getType() == Application.ApplicationType.Android
     || Riiablo.defaultViewport.getWorldHeight() == Riiablo.MOBILE_VIEWPORT_HEIGHT) {
      renderer.zoom(Riiablo.MOBILE_VIEWPORT_HEIGHT / (float) Gdx.graphics.getHeight());
    } else {
      renderer.zoom(Riiablo.DESKTOP_VIEWPORT_HEIGHT / (float) Gdx.graphics.getHeight());
    }
    renderer.resize();
  }
 
Example #3
Source File: JoystickControl.java    From TerraLegion with MIT License 4 votes vote down vote up
public Touchpad getTouchpad() {
	return touchpad;
}