Hi again!
So I’m currently trying to make a touchpad into my game. Im using Libgdx and I noticed that Libgdx offers a Touchpad widget, but its only for Stage2D So my question is if you can still use it outside of Stage2D or if there is any other library out there that offers the same?
Why don’t you just use stage? You can use stage alongside SpriteBatch or whatever you are currently using to render. In fact, you can specify the same sprite batch and shaders to Stage, so that no pipeline switches are needed.
Yes, you can. To check it, simply use:
Gdx.input.getX(); //Touch x
Gdx.input.getY(); //Touch y
Gdx.input.isTouched(); //If it is touched
This, however, won’t give you the right right coordinates. First you have to translate, using something like this:
Camera camera = new Camera();
Vector3.tmp.x = Gdx.input.getX();
Vector3.tmp.y = Gdx.input.getY();
camera.unproject(Vector3.tmp);
float gameX = Vector3.tmp.x;
float gameY = Vector3.tmp.y;
This will give you the correct in game coordinates.
Okay, thanks