how to enable touch or accelerometer controls for libgdx game in browser on mobile device?

Viewed 17

Working on a libgdx game that runs on android, ios, and html problem is I can't figure out how or if it's even possible to enable touch or accelerometer controls for the html version.

I currently use the code below to control movement

ApplicationType appType = Gdx.app.getType();

    if (appType == ApplicationType.Android || appType == ApplicationType.iOS) {
        world.update(deltaTime, Gdx.input.getAccelerometerX());
    } 
    else {
        float accel = 0;
        if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) accel = 5f;
        if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) accel = -5f;
        world.update(deltaTime, accel);
    }

I know using the gyroscope & accelerometer can be used when working with JavaScript but is it possible with libgdx? t

0 Answers
Related