Trust me look into Scene2D.
It handles everything input related for you.
You can even do timed based actions on it, which are very nice.
Its also built into libGDX.
Truuuuust me its super easy once you get the hang of it.
Honestly, I now write everything in Scene2D.
If your having issues getting started with it, Heres a little sample code for you
Stage stage;
ImageButton title; //(there are several types of these, even just simply Image)
InputListener titleListen; //(also several variants)
///----------------------------------------
//init phase
stage = new Stage();
stage.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
Gdx.input.setInputProcessor(stage); //important
titleListen = new InputListener(){
//many different types of inputs to override
@Override
public boolean touchDown(InputEvent event, float x, float y,
int pointer, int button) {
//something
return super.touchDown(event, x, y, pointer, button);
}
};
ImageButtonStyle style = new ImageButtonStyle();
style.up = new TextureRegionDrawable(assets.title); //has to be a textureregion
style.down = new TextureRegionDrawable(assets.title);
title = new ImageButton(style);
title.setSize(title.getWidth()*assets.scaleX, title.getHeight()*assets.scaleY);
title.setPosition(whereever);
stage.addActor(title);//adds it to the Scene
play.addListener(titleListen); //adds the listener
///----------------------------------------
//game loop
//
//
//
stage.act(delta); //updates Scene and grabs inputs
stage.draw(); //draws Scene
world
have agetInput()
method? What is it supposed to do? – congusbongus Apr 2 at 4:39