Joystick - r7perezyera/Virusito GitHub Wiki

Joystick

Constructor class created by the call JoyStick(String fondo, String boton, Body cuerpo).getPad(); to a Touchpad object.

Its dimensions are 240 by 240 and changes the size of the images given to it.

Code needed outside

Code needed to create the body

Global variables

 private World mundo;   
 private Body cuerpo;    

In method

Box2D.init();
mundo = new World(new Vector2(0f,-9.81f), true);
BodyDef def = new BodyDef();
def.type = BodyDef.BodyType.DynamicBody;
def.position.set(0, 0);
cuerpo = mundo.createBody(def);

Screen position

 movingStick.setPosition(x,y);

Add actor

 HUDstage.addActor(pad);