Reputation: 1895
I got a moving square wich moves around in my window and this works fine. But when I try to use public void clicked from libgdx I can't get it to work. This is how my void looks like:
public void clicked(InputEvent event,float x,float y){
rect.y = y;
rect.x = x;
}
Above this im also adding the movement from the box and this works fine so its not rect.y and rect.x. Why aren't rect.y and rect.x changing to the float x and float y from my void when Clicked?
Libgdx Void:
Why isn't this working?
Thanks for reading/helping!
Upvotes: 0
Views: 824
Reputation: 16711
Put this in your game's render
method:
if(Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
rect.x = Gdx.input.getX();
rect.y = Gdx.input.getY();
}
rect
must be defined within your game's class.
Upvotes: 1